I spent a lot of time searching through a number of different regular expressions to find a URL in a body of text and finally ended up with this one - make sure you replace somefile.txt with the file you want to search:
If somebody has a url it fails on, please let me know.
grep -oE '\b(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]*[-A-Za-z0-9+&@#/%=~_|]' somefile.txt
If somebody has a url it fails on, please let me know.