| Thread overview | |||||||||
|---|---|---|---|---|---|---|---|---|---|
|
May 22, 2004 Walter (Phobos): RegExp and dotmatchlf | ||||
|---|---|---|---|---|
| ||||
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 04, 2007 Re: Walter (Phobos): RegExp and dotmatchlf | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Kris | 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 Re: Walter (Phobos): RegExp and dotmatchlf | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Kris | 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 Re: Walter (Phobos): RegExp and dotmatchlf | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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 Re: Walter (Phobos): RegExp and dotmatchlf | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Unknown W. Brackets | 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 Re: Walter (Phobos): RegExp and dotmatchlf | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | 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 06, 2007 Re: Walter (Phobos): RegExp and dotmatchlf | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Unknown W. Brackets | 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.
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply