I'm having a bit of a problem with converting plain text to an url. What I like to have is, if I have text like this: www.google.com, it's converted to
<a href="www.google.com" target="_blank">www.google.com</a>
I'm kind of a RegEx noob, but I tried this:
$description = preg_replace('@(www.([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@', '<a href="$1" target="_blank">$1</a>', $description);
The description var is a piece of text, which CAN contain unconverted url's.
With the code above, I get this as link:
<a target="_blank">www.google.com</a>
So the href part is left out. This must be a piece of cake for you RegEx wizards out there, so thanks in advance for every help.
If there is another (better?) way to convert plain text to url's, you can say so and I'll try it.