URL Pattern

URL Regex Pattern Tester

Validate URLs and web addresses with regular expressions

Example URL Pattern:
^https?:\/\/[\w.-]+(?:\.[\w.-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=]*$
https://www.example.comhttp://subdomain.site.org/pathhttps://app.domain.io/page?id=123

Regex Flags

Click flags to toggle them on/off
//g
88 characters
https://www.example.com http://subdomain.site.org/path https://app.domain.io/page?id=123

No matches found

Pattern Explanation

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

No explanation available

About URL Regex Patterns

URL validation ranges from simple domain matching to complex patterns handling query strings, fragments, authentication, and internationalized domain names. The right pattern depends on your specific requirements.

Our URL regex tester helps you build and test patterns for your use case—whether you need to match simple website links or full URLs with ports, paths, and parameters.

Why Validate URLs?

URLs appear in user input, configuration files, and data imports. Validating them prevents broken links, security vulnerabilities (open redirects), and data quality issues.

Different contexts need different validation: a WordPress comment might only need basic http/https checks, while a security-sensitive application needs to verify the entire URL structure including protocol restrictions.

Building the Pattern

URL regex components:

• Protocol: http:// or https:// (optional for some use cases) • Domain: alphanumeric with hyphens, dot-separated • Port: optional :8080 or similar • Path: optional /path/to/resource • Query: optional ?key=value&other=data • Fragment: optional #section

Combine these components based on what you need to match.

Common Use Cases

  • Validating user-submitted links
  • Extracting URLs from text content
  • Security filtering for allowed domains
  • Data validation in forms

Pro Tip

For user input, consider using the URL constructor in JavaScript—it parses URLs more reliably than regex and throws on invalid input.

Other Regex Patterns