Regex Example

URL Pattern

Matches common HTTP and HTTPS URLs.

Regex Pattern

^https?:\/\/[\w.-]+(?:\.[\w\.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=.]*$

Test Cases

  • https://example.com/path?q=1 - match
  • ftp://example.com - no match
  • http://sub.domain.dev - match

Edge Cases

  • Very strict URL validation is hard with regex alone.
  • IPv6 host parsing often needs dedicated URL parsers.