in reply to A NOT in regular expressions

No guarentees that it will catch every situation, especially as the acknowledged experts are tripping up, but this is my attempt. It seems to work for most cases I can think of and seems somewhat simpler than some of the others.

$_= '1 <% xxx%%> 2 <%%> 3 <%>%> 4 <% >% %> 5 <%%%% xxx %%%%> 6 '; s[ <% .*? (?> %> ) ][!REPLACED!]xg; print; 1 !REPLACED! 2 !REPLACED! 3 !REPLACED! 4 !REPLACED! 5 !REPLACED! 6

Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller