in reply to balanced parens regexp hangs - solved
(?:[^{}]+?|\{(??{$parens})\})*
Such a regex with nested quantifiers is potentially dangerous, because the outer quantifier can force the inner quantifier to backtrack. Use a non-backtracking group (?>...)* instead. (Oh, and why are you using non-greed +? on the [^{}] group? I see no reason for that).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: balanced parens regexp hangs
by grizzley (Chaplain) on Mar 27, 2009 at 08:32 UTC | |
by moritz (Cardinal) on Mar 27, 2009 at 09:07 UTC | |
by grizzley (Chaplain) on Mar 27, 2009 at 10:10 UTC |