[GSOC idea] enhance regular expressions?

Dmitry Olshansky dmitry.olsh at gmail.com
Mon Mar 28 21:24:18 PDT 2011


On 29.03.2011 2:40, bearophile wrote:
> Dmitry Olshansky:
>
>> BTW which ones? Now is the time to propose them.
> Verbose regular expressions, that allow to put space and comments, to format REs more like code and less like a cryptic puzzle language.
>
> (?:...) A non-grouping version of regular parentheses. Matches whatever regular expression is inside the parentheses, but the substring matched by the group cannot be retrieved after performing a match or referenced later in the pattern.
>
> (?P<name>...) Similar to regular parentheses, but the substring matched by the group is accessible via the symbolic group name name. A symbolic group is also a numbered group.
>
> (?P=name) Matches whatever text was matched by the earlier group named name.
>
> (?=...) Lookahead assertion. Matches if ... matches next, but doesn't consume any of the string.
>
> (?!...) Negative lookahead assertion. Matches if ... doesn't match next. The contained pattern must only match strings of some fixed length.
>
> (?<=...) Positive lookbehind assertion. Matches if the current position in the string is preceded by a match for ... that ends at the current position. The contained pattern must only match strings of some fixed length.
>
> (?<!...) Negative lookbehind assertion. Matches if the current position in the string is not preceded by a match for .... The contained pattern must only match strings of some fixed length. Patterns which start with negative lookbehind assertions may match at the beginning of the string being searched.
>
Yeah, that's something I vaguely called "... not implemented features it 
may very well have had".

More then that (?:...), (?!...), (?<=...) area part of ECMA v3 spec. And I got a preliminary support for them in my patch herehttp://d.puremagic.com/issues/show_bug.cgi?id=5673.
Others (except (?P<name>) and (?P=name) ) also considered common extensions and I planed to add them plus  regex comment (#...) where all of ... simply have no effect on matching.


> Bye,
> bearophile


-- 
Dmitry Olshansky



More information about the Digitalmars-d mailing list