http://www.perlmonks.org?node_id=398325


in reply to How to recognize url in text and convert to hyperlink, unless already in anchor

All you need to do is look for the links as you are doing, but make sure that the links are preceeded, and optionally followed, by whitespace.

This will never by true for something inside an A tag.

(Yes the real solution is to use a package from CPAN for recognising URLS, and parsing, but this is a hack on your hack).

You could use the following:

$myformtext =~ s!(\s)(http://\w.*?)(\s)!$1<a href="$2">$2</a>$3!gm;
Steve
---
steve.org.uk
  • Comment on Re: How to recognize url in text and convert to hyperlink, unless already in anchor
  • Download Code

Replies are listed 'Best First'.
Re^2: How to recognize url in text and convert to hyperlink, unless already in anchor
by tachyon (Chancellor) on Oct 12, 2004 at 06:31 UTC

    This will never by true for something inside an A tag.

    Except when it is of course, like here: bamb