www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Walter (Phobos): RegExp and dotmatchlf

reply "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
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
next sibling parent yidabu <yidabu.douspam gmail.com> writes:
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,
 
 - Kris
 
 
fixed? seems not!
May 04 2007
prev sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
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
parent reply "Unknown W. Brackets" <unknown simplemachines.org> writes:
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
parent reply Walter Bright <newshound1 digitalmars.com> writes:
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
parent reply "Unknown W. Brackets" <unknown simplemachines.org> writes:
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
parent torhu <fake address.dude> writes:
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