RegExp "." dos not match any character, as it misses newline
torhu
fake at address.dude
Fri May 4 02:33:04 PDT 2007
yidabu wrote:
> code:
> import std.stdio;
> import std.regexp;
>
> void main()
> {
> char[] str = r"a
> b";
> char[] pattern = ".+";
> if ( RegExp(pattern).test(str) )
> {
> str = RegExp(pattern).match(str)[0];//无论用什么Attribute,总是只匹配第一行的a,也就是.无法跨行
> writefln(str);
> }
> else {writefln("failed");}
> }
>
> output:a
>
> seems "." dos not match any character, as it misses newline
That's the way regexes work. I wish the docs for "." would say "Matches
any character, except a newline". Because people have asked this before.
Good regex tester here, much easier to try out stuff:
http://www.stringtools.com/
More information about the Digitalmars-d-bugs
mailing list