digitalmars.D - Walter (Phobos): RegExp and dotmatchlf
- Kris (8/8) May 21 2004 std.RegExp has an attribute 'dotmatchlf' for including newlines in a mat...
- yidabu (3/16) May 04 2007 fixed?
- Walter Bright (2/5) May 04 2007 I left it off because there didn't seem to be a standard way of doing it...
- Unknown W. Brackets (5/12) May 05 2007 Well, in PCRE you use something like this:
- Walter Bright (3/9) May 05 2007 I've never seen it as a regex constructor flag. Regexes are standardized...
- Unknown W. Brackets (16/26) May 05 2007 Really? It seems to be available many places:
- torhu (4/27) May 05 2007 Python supports it too, as a flag to many of its regex functions. It's
std.RegExp has an attribute 'dotmatchlf' for including newlines in a match for '.' but there's currently no way to enable that using the RegExp() constructor. Is this an oversight? Or is there another way to enable it? Would be handy to have that instead of writing (.|\n)* all the time ... BTW, I thought that [.\n]* would be equivalent to (.|\n)* as far as searching is concerned, but it doesn't give the same results ... Cheers, - Kris
May 21 2004
Kris Wrote:std.RegExp has an attribute 'dotmatchlf' for including newlines in a match for '.' but there's currently no way to enable that using the RegExp() constructor. Is this an oversight? Or is there another way to enable it? Would be handy to have that instead of writing (.|\n)* all the time ... BTW, I thought that [.\n]* would be equivalent to (.|\n)* as far as searching is concerned, but it doesn't give the same results ... Cheers, - Krisfixed? seems not!
May 04 2007
Kris wrote:std.RegExp has an attribute 'dotmatchlf' for including newlines in a match for '.' but there's currently no way to enable that using the RegExp() constructor. Is this an oversight? Or is there another way to enable it?I left it off because there didn't seem to be a standard way of doing it.
May 04 2007
Well, in PCRE you use something like this: ~a(.+)b~s Where s is also known as "dotall". So, why not add it as a flag in the constructor? I'm pretty sure I've seen it used outside Perl too. -[Unknown]Kris wrote:std.RegExp has an attribute 'dotmatchlf' for including newlines in a match for '.' but there's currently no way to enable that using the RegExp() constructor. Is this an oversight? Or is there another way to enable it?I left it off because there didn't seem to be a standard way of doing it.
May 05 2007
Unknown W. Brackets wrote:Well, in PCRE you use something like this: ~a(.+)b~s Where s is also known as "dotall". So, why not add it as a flag in the constructor? I'm pretty sure I've seen it used outside Perl too.I've never seen it as a regex constructor flag. Regexes are standardized enough I am very reluctant to create a unique variant.
May 05 2007
Really? It seems to be available many places: Perl uses it, as I mentioned: http://perldoc.perl.org/perlre.html#DESCRIPTION .NET uses it too: http://msdn2.microsoft.com/en-us/library/yd1hzczs.aspx And of course, PCRE which allows the modifier ?s as well. But it, like Java, uses it as an int constant in a bitfield flag or similar. Boost calls it "mod_s" for obvious reasons: http://www.boost.org/libs/regex/doc/syntax_option_type.html#Table5 JavaScript/ECMAScript notably does not support it. But, XSLT 2.0/XPath 2.0 do include a recommendation for its support: http://www.w3.org/TR/xslt20/#regular-expressions http://www.w3.org/TR/xpath-functions/#flags I would suggest that you wouldn't be in danger of exploring new territory if you considered this as a flag. -[Unknown]Unknown W. Brackets wrote:Well, in PCRE you use something like this: ~a(.+)b~s Where s is also known as "dotall". So, why not add it as a flag in the constructor? I'm pretty sure I've seen it used outside Perl too.I've never seen it as a regex constructor flag. Regexes are standardized enough I am very reluctant to create a unique variant.
May 05 2007
Unknown W. Brackets wrote:Really? It seems to be available many places: Perl uses it, as I mentioned: http://perldoc.perl.org/perlre.html#DESCRIPTION .NET uses it too: http://msdn2.microsoft.com/en-us/library/yd1hzczs.aspx And of course, PCRE which allows the modifier ?s as well. But it, like Java, uses it as an int constant in a bitfield flag or similar. Boost calls it "mod_s" for obvious reasons: http://www.boost.org/libs/regex/doc/syntax_option_type.html#Table5 JavaScript/ECMAScript notably does not support it. But, XSLT 2.0/XPath 2.0 do include a recommendation for its support: http://www.w3.org/TR/xslt20/#regular-expressions http://www.w3.org/TR/xpath-functions/#flags I would suggest that you wouldn't be in danger of exploring new territory if you considered this as a flag.Python supports it too, as a flag to many of its regex functions. It's called 'S', with the alias 'DOTALL'. An 's' attribute for Phobos would be a welcome addition.
May 05 2007