[regex-coach] Possessive Quantifier + Problem with the Regex Coach
Edi Weitz
edi at agharta.de
Fri Apr 16 19:13:55 UTC 2004
On Fri, 16 Apr 2004 14:01:23 -0400, "Seen Sai Yang" <whollyanointed at hotmail.com> wrote:
> I tried an example from the Regex Tutorial
> (http://www.regular-expressions.com/atomic.html) with the following
> regex (at the bottom of the page):
>
> \d++6 gave an error "Quantifier '+' not allowed at position 3"
>
> The same regex worked in PowerGREP.
Hi!
The Regex Coach tries to be compatible with Perl. Perl does not allow
the '++' notation for 'possesive' quantifiers, you have to use
'(?>...)' instead:
edi at bird:~ > perl -v
This is perl, v5.8.1 built for i586-linux-thread-multi
Copyright 1987-2003, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using `man perl' or `perldoc perl'. If you have access to the
Internet, point your browser at http://www.perl.com/, the Perl Home Page.
edi at bird:~ > perl -le 'print 1 if "123456" =~ /\d++6/'
Nested quantifiers in regex; marked by <-- HERE in m/\d++ <-- HERE 6/ at -e line 1.
edi at bird:~ > perl -le 'print 1 if "123456" =~ /(?>\d+)6/'
edi at bird:~ > perl -le 'print 1 if "123456" =~ /(?>\d+)/'
1
edi at bird:~ > perl -le 'print 1 if "123456" =~ /\d+6/'
1
Cheers,
Edi.
More information about the regex-coach
mailing list