Detecting URLs within a string PHP and Javascript

I had to roll my own regex solution for translating embedded links within text to clickable html links. Stuff on the web had too many false positives. Hope it helps!





Properly detects the urls in the following formats:

Screen Shot 2013-03-20 at 1.59.53 PM

Including subpaths:

Screen Shot 2013-04-08 at 1.37.11 PM