I am using the following regex to match a URL:
$search = \"/([\\S]+\\.(MUSEUM|TRAVEL|AERO|ARPA|ASIA|COOP|INFO|NAME|BIZ|CAT|COM|INT|JOBS|NET|ORG|PRO|TEL|AC|A
This question was surprisingly difficult to find an answer for. The regexes I found were too complicated to understand, and anything more that a regex is overkill and too difficult to implement.
Finally came up with:
/(\S+\.(com|net|org|edu|gov)(\/\S+)?)/
Works with http://example.com, https://example.com, example.com, http://example.com/foo.
Explanation: