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";
In reply to Re: Substitute for variable-length look-behind?
by sleepingsquirrel
in thread Substitute for variable-length look-behind?
by diotalevi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |