I think it's worth repeating what tilly and mstone
have mentioned; that is, matching balanced delimiters
cannot be done with a (formal) regular expression. Perl's
"regexes", however, are more powerful than (formal) regular
expressions, and (with some contortions) can match
balanced delimiters.
For the sake of whoever maintains your code, though, use
Text::Balanced instead, and keep the gnarly regexes
in reserve for when they're the best tool for the job.
--
:wq
| [reply] |