URL & Domain Regular Expression Studio
Construct and test web link regular expressions with our URL Regex Studio! Build robust patterns matching HTTP/HTTPS protocols, fully qualified domain names (FQDN), IP addresses, custom port numbers (`:8080`), path hierarchies, query parameters (`?key=val`), and hash anchor fragments (`#section`).
Select Preset Rules
Pattern Tokens Explanation
Here is a step-by-step breakdown of how regular expression engines evaluate your formulated URL validation rules:
Reference Patterns
| Validation Format | Match Example | Regex Snippet |
|---|---|---|
| Strict HTTPS Only | https://example.com | ^https:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?$ |
| HTTP & HTTPS Standard | http://website.org | ^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?$ |
| Optional Protocol Prefix | www.google.com | ^(?:https?:\/\/)?(?:www\.)?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?$ |
| Requires WWW Domain Prefix | https://www.google.com | ^https?:\/\/www\.[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?$ |
| Absolute Local Path Only | /images/banner.png | ^\/(?:[\w.-]+\/)*[\w.-]*$ |
| Multi Subdomain Wildcard | https://api.dev.site.co | ^https?:\/\/(?:[\w-]+\.)+[\w-]{2,}(?:\/\S*)?$ |
| Localhost Loopback Port | http://localhost:8080 | ^https?:\/\/localhost(?::\d+)?(?:\/\S*)?$ |
| IPv4 Host Domain | http://192.168.1.1 | ^https?:\/\/(?:\d{1,3}\.){3}\d{1,3}(?::\d+)?(?:\/\S*)?$ |
| Strict TLD Range Limit | https://agency.travel | ^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}(?:\/\S*)?$ |
| URL with Query Parameters | https://site.com/search?q=query | ^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/[\w.-]*)*\?(?:\w+=\w+)(?:&\w+=\w+)*$ |
| URL with Hash Fragment | https://site.com/docs#intro | ^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?#[\w-]+$ |
| FTP Protocol Standard | ftp://files.server.net | ^ftp:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?$ |
Entropy Analysis
| Character Pool Segment | Dimension Size | Entropy Bits/Char |
|---|---|---|
| Digits (0-9) | 10 | 3.32 bits |
| Lowercase letters (a-z) | 26 | 4.70 bits |
| Uppercase letters (A-Z) | 26 | 4.70 bits |
| Protocol elements (://) | 3 | 1.58 bits |
| Separator Dot (.) | 1 | 1.00 bits |
| Query delimiter (?) | 1 | 1.00 bits |
| Hash delimiter (#) | 1 | 1.00 bits |
| Port delimiter (:) | 1 | 1.00 bits |
Entropy Analysis in regular expressions evaluates the information density and structural complexity of matched patterns based on Shannon's Entropy formula ($H = -\\sum P_i \\log_2 P_i$). Here is how it works:
- Information Density: Measures the unpredictability and strictness of character classes. A pattern with higher entropy restricts inputs more precisely, leaving fewer opportunities for structural anomalies.
- Character Pool Segmenting: Breaks down matched values into operational blocks (digits, spaces, hyphens, prefixes, parentheses) and calculates their corresponding bit pools.
- ReDoS Vulnerability Protection: Helps developers analyze pattern backtracking depth. Low-entropy, overly loose patterns (like overlapping wildcards) can trigger catastrophic backtracking, causing servers to hang under ReDoS exploits. High-entropy, precise patterns mitigate this risk.
Overview & Capabilities
Construct and test web link regular expressions with our URL Regex Studio! Build robust patterns matching HTTP/HTTPS protocols, fully qualified domain names (FQDN), IP addresses, custom port numbers (:8080), path hierarchies, query parameters (?key=val), and hash anchor fragments (#section).
How to Use
http:// optional), or Domain Hostname Only.:8080), or allow localhost.Key Features
http, https, ftp), host, port, path, query, and fragments.http:// or https:// prefixes.?id=10&tab=profile) and percent-encoded characters.Frequently Asked Questions
Q Which regular expression validates standard HTTP and HTTPS web URLs?
`^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$` matches standard secure and unencrypted web links.
Q How do you validate a domain name without the protocol?
`^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2}$` validates standard domain hostnames like `example.com` or `sub.domain.co.uk`.
Q Can this regex match URLs with query parameters and hash anchors?
Yes! The pattern includes character classes capturing query parameters (`?key=value&id=123`) and URL fragments (`#section-2`).



