in reply to A NOT in regular expressions
Taking into account all the problems with writing a regexp for balanced delimiters I wonder how it can work in the generall case, but I hope it works.
Update: It's not really equivalent to the other proposed solutions. But it has a clear semantics that shoul be applicable in many cases.
Here is an example:
and the output:use Regexp::Common qw /balanced/; $r = qr/$RE{balanced}{-begin => "<%"}{-end => "%>"}/; @list = ("aa<% <% %>bb", "aa<% %> <% %>bb", "aa<% <% %> %>bb", "aa<% > +% %>bb"); for (@list){ /($r)/; print "$` \t| $1 \t| $'\n"; }
aa<% | <% %> | bb aa | <% %> | <% %>bb aa | <% <% %> %> | bb aa | <% >% %> | bb
|
|---|