Hi all! If you use URI::Find and Email::Find on "plain text" files -- and you sometimes encounter HTML HREF tags in these files, you know how these modules can mangle your output. So, here's a quickie fix to make the modules smarter.

Credit where credit is due -- suaveant reminded me about negative lookaheads last month when I was trying to highlight keywords in my site search output. This is the same concept -- and the same code! Thanks, dood!
Add the negative lookaheads:
# URI::Find line 124 # $$r_text =~ s{(<$uriRe>|$uriRe)}{ # OLD $$r_text =~ s{(<$uriRe>|$uriRe)(?![^<]*[>\Z])}{ # NEW # Email::Find line 59 # $$r_text =~ s{($Addr_spec_re)}{ # OLD $$r_text =~ s{($Addr_spec_re)(?![^<]*[>\Z])}{ # NEW
  • Comment on Fixing URI::Find and Email::Find to ignore URI's and e-mail addys in HTML tags
  • Download Code