in reply to Substitute for variable-length look-behind?
while (m(<code>|\[|<!--)g) { if ($& eq '<code>') { s{\G(.+?)</ code>}{$GREEN$1$RESET}; pos($_) += length("$GREEN$1$RESET"); } elsif ($& eq '[') { s{\G(.+?)\]}{$RED$1$RESET}; pos($_) += length("$RED$1$RESET"); } elsif ($& eq '<!--') { s{\G(.+?)-->}{$YELLOW<!--$1$-->RESET}; pos($_) += length("$YELLOW$1$RESET"); } }
|
---|