in reply to Re^2: Match a pattern only if it is not within another pattern
in thread Match a pattern only if it is not within another pattern
If you want to learn to solve the general problem, the book "Mastering Regular Expressions" is highly recommended. If you want a solution to the general problem, Regexp::Common::balanced does it already.
# note, this matches "qux foo bar" and "bar foo qux", but not "bar foo + bar" # see Regexp::Common::balanced documentation for details qr/$RE{balanced}{-begin => "qux|bar"}{-end => "bar|qux"}/
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|