On Fri, 16 Apr 2004 14:01:23 -0400, "Seen Sai Yang" whollyanointed@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@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@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@bird:~ > perl -le 'print 1 if "123456" =~ /(?>\d+)6/' edi@bird:~ > perl -le 'print 1 if "123456" =~ /(?>\d+)/' 1 edi@bird:~ > perl -le 'print 1 if "123456" =~ /\d+6/' 1
Cheers, Edi.