๐Ÿ”—

Advanced URL Regex Generator

Generate highly robust regular expressions to match, extract, or validate URL addresses. Instantly test individual formats or process values in bulk.

โœจ 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.