Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I have a form that the user is allowed to type plain text and/or HTML into. I need to recognize urls within this text that have not already been wrapped in an anchor <A HREF> tag, and then wrap them so they end up as hyperlinks. If already wrapped, I want to leave them alone.
I have an expression that does this for the whole string:
But can I somehow apply this only to the portion of the text that is not within an <A HREF> tag? Maybe split it or something? I'm not a perl expert...$myformtext =~ s!(http://[^\s]+)!<a href="$1">$1</a>!gi;
20041011 Edit by ysth: add p and code tags
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to recognize url in text and convert to hyperlink, unless already in anchor
by pizza_milkshake (Monk) on Oct 11, 2004 at 23:19 UTC | |
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 | |
by tachyon (Chancellor) on Oct 12, 2004 at 06:31 UTC | |
Re: How to recognize url in text and convert to hyperlink, unless already in anchor
by pingo (Hermit) on Oct 12, 2004 at 09:33 UTC | |
by zakzebrowski (Curate) on Oct 12, 2004 at 11:19 UTC | |
Re: How to recognize url in text and convert to hyperlink, unless already in anchor
by DrHyde (Prior) on Oct 12, 2004 at 08:51 UTC | |
Re: How to recognize url in text and convert to hyperlink, unless already in anchor
by Anonymous Monk on Oct 13, 2004 at 11:07 UTC |
Back to
Seekers of Perl Wisdom