๐Ÿ”—

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`).

โœจ NLP PROMPT ENGINEType your URL parameters in plain English to formulate custom regex patterns instantly
๐Ÿ”ฎ
Or try prompts:

Select Preset Rules

โš™๏ธ URL Configurator

Protocol & Schema Settings

Domain & Resource Extensions

Generated URL Regex Pattern
^https?:\/\/(?:www\.)?(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}|(?:\d{1,3}\.){3}\d{1,3})(?:\/[\w\.-]*)*(?:\?[\w\.\/-]*=[\w\.\/-]*(&[\w\.\/-]*=[\w\.\/-]*)*)?(?:#[\w-]*)?$
Export Code Snippet:

๐Ÿงช Live Interactive Validator

https://www.example.com/path?query=1#hash
PASSED: URL satisfies formulated constraints.

๐Ÿ“Š Bulk Testing Lab

https://google.com โœ“ PASS
ftp://invalid.com โœ— FAIL
localhost:8080 โœ— FAIL
www.test.co.uk/page โœ— FAIL
http://192.168.1.1 โœ“ PASS

๐Ÿ“– Pattern Tokens Explanation

Here is a step-by-step breakdown of how regular expression engines evaluate your formulated URL validation rules:

Start Anchor (^)Asserts that the regex engine must start validation at the absolute beginning of the string value.
^
Protocol SchemaRequires standard schemas like HTTP / HTTPS.
https?:\/\/
Hostname & Host extensionAllows traditional domains (TLDs) or IPv4 address spaces (e.g. 192.168.1.1).
(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}|(?:\d{1,3}\.){3}\d{1,3})
Request Path SegmentMatches standard resource paths separated by slash dividers.
(?:\/[\w\.-]*)*
Query Parameters GroupValidates key-value parameters pairs trailing after query signifiers.
(?:\?[\w\.\/-]*=[\w\.\/-]*(&[\w\.\/-]*=[\w\.\/-]*)*)?
End Anchor ($)Asserts that the regex engine must conclude validation at the absolute end of the input string, disallowing trailing junk characters.
$

๐Ÿ“Š Reference Patterns

Validation FormatMatch ExampleRegex Snippet
Strict HTTPS Onlyhttps://example.com^https:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?$
HTTP & HTTPS Standardhttp://website.org^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?$
Optional Protocol Prefixwww.google.com^(?:https?:\/\/)?(?:www\.)?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?$
Requires WWW Domain Prefixhttps://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 Wildcardhttps://api.dev.site.co^https?:\/\/(?:[\w-]+\.)+[\w-]{2,}(?:\/\S*)?$
Localhost Loopback Porthttp://localhost:8080^https?:\/\/localhost(?::\d+)?(?:\/\S*)?$
IPv4 Host Domainhttp://192.168.1.1^https?:\/\/(?:\d{1,3}\.){3}\d{1,3}(?::\d+)?(?:\/\S*)?$
Strict TLD Range Limithttps://agency.travel^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}(?:\/\S*)?$
URL with Query Parametershttps://site.com/search?q=query^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/[\w.-]*)*\?(?:\w+=\w+)(?:&\w+=\w+)*$
URL with Hash Fragmenthttps://site.com/docs#intro^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?#[\w-]+$
FTP Protocol Standardftp://files.server.net^ftp:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?:\/\S*)?$

๐Ÿงฌ Entropy Analysis

Character Pool SegmentDimension SizeEntropy Bits/Char
Digits (0-9)103.32 bits
Lowercase letters (a-z)264.70 bits
Uppercase letters (A-Z)264.70 bits
Protocol elements (://)31.58 bits
Separator Dot (.)11.00 bits
Query delimiter (?)11.00 bits
Hash delimiter (#)11.00 bits
Port delimiter (:)11.00 bits
๐Ÿ”ฌ What is Entropy Analysis?

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).

Tutorial

How to Use

01
Select your URL validation standard: Strict Full URL, Optional Protocol (http:// optional), or Domain Hostname Only.
02
Configure options: Allow IP addresses as hostnames, allow custom port numbers (:8080), or allow localhost.
03
Inspect the generated regex in the terminal.
04
Test web addresses in the interactive link verification pane.
05
Export regex validation code for frontend form inputs and backend web crawlers.
Capabilities

Key Features

RFC 3986 URI Specification Compliance: Matches protocol scheme (http, https, ftp), host, port, path, query, and fragments.
Optional Protocol Matching: Captures links with or without leading http:// or https:// prefixes.
Top-Level Domain (TLD) Quantifier: Restricts domain extensions to 2โ€“24 alphabetic characters.
Deep Query String Matcher: Captures key-value pairs (?id=10&tab=profile) and percent-encoded characters.
In-Browser Test Engine: Evaluates web links in local memory.
Answers

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`).