in reply to RE: RE (tilly) 2: Regex'ing backreferences
in thread Regex'ing backreferences

Your current regex is:
m{ foo ( # save to $1 [^b]* # 0 or more non-b characters (?: b+ # 1 or more b's (?: a(?!r) # an 'a' NOT followed by an 'r' | # or [^a] # a non-a character ) [^b]* # 0 or more non-b characters )* # that whole b... subset, 0 or more times ) foo # and foo }x;
That incorrectly matches "foobbarfoo".

Again, optimization is the root of all evil. :-)

Replies are listed 'Best First'.
RE: RE (tilly) 4 (good try): Regex'ing backreferences
by japhy (Canon) on Sep 21, 2000 at 18:28 UTC
    Ok. Changed it:
    m{ foo ( # save to $1 [^b]* # 0 or more non-b characters (?: (?>b+) # 1 or more b's (NO BACKTRACKING!) (?: a(?!r) # an 'a' NOT followed by an 'r' | # or [^a] # a non-a character ) [^b]* # 0 or more non-b characters )* # that whole b... subset, 0 or more times ) foo # and foo }x;


    $_="goto+F.print+chop;\n=yhpaj";F1:eval