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:
$myformtext =~ s!(http://[^\s]+)!<a href="$1">$1</a>!gi;
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...
20041011 Edit by ysth: add p and code tags