in reply to Recursive regular expression weirdness
... our $rxNest; $rxNest = qr{(?x) ( \( [^()]* (?: (??{$rxNest}) [^()]* )* \) ) (?{ [ @{$^R}, $1 ] }) }; our $rxOnlyNested = qr{(?x) (?{ [] }) ^ [^()]* (?: $rxNest [^()]* )* \z (?{ @memoList = @{$^R} }) }; ... if ($string =~ $rxOnlyNested) ...
Note that @memoList is now correct whether there is backtracking or not, thanks to the use of $^R.
Note that I used $1 instead of $+. Using $+ will negatively impact on the performance of all regexps without captures executed in that perl interpreter instance, whereever they are located.
Update: Removed unnecessary parens. (Copy and paste bug.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Recursive regular expression weirdness
by johngg (Canon) on Mar 30, 2006 at 11:44 UTC | |
by ikegami (Patriarch) on Mar 30, 2006 at 15:41 UTC | |
by johngg (Canon) on Mar 30, 2006 at 18:45 UTC | |
by ikegami (Patriarch) on Mar 30, 2006 at 19:05 UTC | |
by johngg (Canon) on Mar 30, 2006 at 20:19 UTC |