I tried to take into account a number of additional url syntax rules (without getting into internationalisation). If you also want to allow query strings without slash before the question mark (which is theoretically not allowed, but works in most real-life situations) the regex is "^(https? $"If you also want to make sure that every % is followed by a hex number, the regex is "^(https? [a-z0-9][-a-z0-9][a-z0-9]\.[a-z])|((\d\.)\d))(:\d)?
:" // IP address exclusion // private & local networks "(?! The actual URL syntax is pretty complicated and not easy to represent in regex. Most of the simple-looking regexes out there will give many false negatives as well as false positives. Also, single weird leading and/or trailing characters aren’t tested for. Just imagine you’re doing this before testing modifier to all the regexes to speed up the tests. Here’s a plain text list of all the URLs used in the test.