Recognize "Invalid" URLs without Trying to Resolve Them <p>I'm building a Facebook App which grabs the URLs from various sources in a user's Facebook acount--e.g., a user's likes.</p> <p>A problem I've encountered is that many Facebook entries have string which are not URLs in their "website" and "link" fields. Facebook does no checking on user input so these fields can essentially contain any string.</p> <p>I want to be able to process the strings in these field such that URLs like <code>"http://google.com"</code>, <code>"https://www.bankofamerica.com"</code>, <code>"http://www.nytimes.com/2011/06/13/us/13fbi.html?_r=1&amp;hp"</code>, <code>"bit.ly"</code>, <code>"www.pbs.org"</code> are all accepted.</p> <p>And all the strings like <code>"here is a random string of text the user entered"</code>, <code>"here'\s ano!!! #%#$^ther weird random string"</code> are all rejected.</p> <p>It seems to me the only way to be "sure" of a URL is to attempt to resolve it, but I believe that will be prohibitively resource intensive.</p> <p>Can anyone think of clever way to regex or otherwise analyze these strings such that "a lot" of the URLS are properly captured--80%? 95% 99.995% of URLs?</p> <p>Thanks!</p> <hr> <p>EDIT: FYI, I'm developing in Python. But a language agnostic solution is great as well.</p>