Programming Windows D Examples are now Online!
Dmitry Olshansky
dmitry.olsh at gmail.com
Thu Jun 23 09:44:04 PDT 2011
On 23.06.2011 9:58, Andrej Mitrovic wrote:
> Fixed: https://github.com/AndrejMitrovic/DWindowsProgramming/commit/42228c9012c2c75d2638fab52277f21427b2ed01
>
> Quite a huge list of stray parens. Good thing I had Beyond Compare for
> the diffs.
Seems like I'm late for regex party :(
Still, this works in D2, and is somewhat intelligent ;)
import std.regex, std.file;
void main(string[] args)
{
auto r = regex(`(\W\s*)\(("(?:[^"]|\\")*")\)`,"g");
foreach(arg; args[1..$])
{
auto data = cast(string)read(arg);
auto replaced = replace(data, r, `$1$2`);
std.file.write(arg, replaced);
}
}
--
Dmitry Olshansky
More information about the Digitalmars-d-announce
mailing list