in reply to Substitute for variable-length look-behind?
use Term::ANSIColor ':constants'; # Note that there is not normally an 'x' betweeh the </ and code>. I # added that so that Perlmonks.org wouldn't parse the post incorrectly +. $_ = "normal <code> green <!-- yellow [red] normal --> normal </xcode> ++ normal"; $delimit{"code"} = GREEN; $delimit{"--"} = YELLOW; $delimit{"]"} = RED; $RESET = RESET; s{ (?:<code>(.+?)</x(code)>) | (?:(?<=\x1b)\[(.+?)(\])) | (?:(<!--.+?(--)>)) }{$delimit{$2|$4|$6}.($1|$3|$5).$RESET}egx; print "$_\n";
|
---|