in reply to Highlight your result
Greetings tune. First off, you should definately look into HTML::Parser if you want to play around with regex in HTML documents. Trust me, I've been burned on this several times. However, just because I'm curious and want to practice my still young regex skills, I decided to play around with a solution:
$string = 'Some mp3 at <a href="mp3.com">mp3.com</a> with mp3 stuff.'; $search = 'mp3'; $string =~ s#(<[^>]*>[^<]*)($search)|^([^<]*)($search)#$1$3<b>$2$4</b> +#g;
This seems to work, as far as I can tell. I haven't really tested it with anything complex, but I'd say that chances are it would break in real-world use. So use HTML::Parser instead.
-gryphon
code('Perl') || die;
|
|---|