in reply to Re: RexExp help: Highlight keywords in CGI search results, unless inside an HTML tag
in thread RexExp help: Highlight keywords in CGI search results, unless inside an HTML tag

Thanks, Chady!

suaveant gave me this little hunk of code that seems to be working great:
$text =~ s|($keyword)(?![^<]*[>\Z])|<B>$1</B>|img;
I've never used that explicit lookahead before. I love/hate it when I'm shown something so useful (when I should have known it before). I KNOW I read pp. 228-230 of Mastering Regular Expressions one day last year... :)
  • Comment on Re: Re: RexExp help: Highlight keywords in CGI search results, unless inside an HTML tag
  • Download Code