overlapping find and replace

Mike Whitaker mike at altrion.org
Mon Oct 18 16:14:23 BST 2010


You are aware that's illegal XHTML, aren't you? :D

On 18 Oct 2010, at 16:11, Michael Lush wrote:

> 
> 
> I have a string ABCDEFGH and want to highlight two overlapping hits
> BCDE and DEFG in HTML to make A<b>BC<i>DE</b>FG</i>H
> 
> The obvious $string =~ s{(BCDE|DEFG)}{<b>$1</b>}g; does not work as the modified string doesn't match the second query and I don't get differnet
> fonts for each overlapping match.
> 
> Is there a conventional way of doing this?
> 
> --
> Michael




More information about the london.pm mailing list