How do I do a replace that will turn all plain addresses in a paragraph in to links?
The problem is periods are valid in the address, but the address may be at the end of a sentence.
Test string:
The link is: http://www.google.com/pants. And that is the link.
I need to group out from http to pants. (It is plain text and I need to make it html.)
This regex grabs the period after pants and so is bad:
(^|[\n ])([\w]+?://[^\s]*)
I'm pretty sure I need to do a lookahead, but I can't put that in the ^\s character set. Trying to do an ifthenelse has also eluded me.
Here is my output thingy:
$1<a href=\"$2\" target=\"_blank\">$2</a>
Hey, people reading this. Make sure you know this site: http://gskinner.com/RegExr/ It rules. It's the only reason I get any regex right.