Regex To Match All Parameters In A URL

A regular expression to match all parameters (anything after the ?) in a URL.

/(\?|\&)([^=]+)\=([^&]*)/g

Matches:

  • https://regexpattern.com/query.php?query=true&para=123&bar=456
  • https://regexpattern.com/query.php?query=&para=123&bar=456
  • https://www.behance.net/search?sort=published_date&search=free%20psd

Non-matches:

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

See Also: