in reply to Re: Highlighting a text inside another one.
in thread Highlighting a text inside another one.

thanks Dave you've got a pretty good idea of my motives, although for the moment I'm not concerned about the order in which I find the extracted words, because I intend to move them around.

The huge gnarly regex option is attractive because the engine does most of the work and yes, if I could do it it would be, uh, cool.

but won't it be bloody slow?

The alternative I'm contemplating is to just run loads of regexes to wrap tags round every word on my "wish list", so that I get Bill >> <subvert pos="6">Bill</subvert>

I'm already having to use a lookahead & lookbehind to avoid matching html attributes, so I just add something that ignores anything inside subvert tags, and finally turn all the subvert tags into spans.

Sure, this could be done with one regex but I suspect (complete airy hypothesis) that it will be slower.

of course, the thing to do is to do it both ways.