URL (With And Without Port Number) Regular Expressions

Category: URI

A regular expression to match all valid URLs with port numbers, hashes(#), and parameters (&).

/^(((ht|f)tps?):\/\/)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\[email protected]?^=%&/~+#-])?$/

If you’re looking for a regex that matches a URL with a port number:


URL Examples:

  • https://regexpattern.com/
  • https://regexpattern.com/#/a=1&b=2
  • https://regexpattern.com/:8080
  • ftps://regexpattern.com/

See Also:

Rate This Regex
User Review
0 (0 votes)

Expression Flags

Flags Description
i Ignore case sensitive.
g Allows global search.
m Allows multiline search.