Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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

by skx (Parson)
on Oct 11, 2004 at 22:54 UTC ( #398325=note: print w/ replies, xml ) Need Help??


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
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://398325]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (14)
As of 2014-12-18 15:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (56 votes), past polls