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
Changing the end of the regex to (/\S*)?)$ should solve your problem.
To explain what that is doing -
/ followed by some characters (not whitespace) ? indicated 0 or 1 times \b for matching on a word boundary).