Regex Pattern Library
Browse 100+ ready-to-use regular expression patterns across 11 categories. Each pattern includes an interactive live tester, code examples, and detailed explanations.
Validation
(8)Email Address
BeginnerValidates standard email addresses with username, @ symbol, domain, and TLD. Covers most common email formats used in web forms.
Phone Number (US)
BeginnerMatches US phone numbers in common formats including with/without country code, parentheses, dashes, dots, and spaces.
Phone Number (International)
IntermediateValidates international phone numbers following the E.164 standard. Supports 1-15 digits with optional plus prefix.
URL
IntermediateMatches HTTP and HTTPS URLs with optional www prefix, domain, path, query parameters, and fragments.
IPv4 Address
IntermediateValidates IPv4 addresses ensuring each octet is 0-255. Commonly used in network tools, log analysis, and security applications.
IPv6 Address
AdvancedMatches full IPv6 addresses in standard notation with 8 groups of 4 hexadecimal digits separated by colons.
MAC Address
BeginnerValidates MAC addresses in colon or hyphen-separated format with 6 groups of 2 hexadecimal digits.
Domain Name
IntermediateValidates domain names with proper label formatting, supporting subdomains and various TLD lengths.
Numbers
(8)Integer
BeginnerMatches whole numbers including negative values. Simple pattern for validating integer input in forms or data processing.
Decimal Number
BeginnerMatches integers and decimal numbers with optional negative sign. Allows trailing decimals for flexible number parsing.
Currency (USD)
IntermediateValidates US dollar amounts with optional dollar sign, comma-separated thousands, and exactly two decimal places.
Percentage
BeginnerMatches percentage values with optional decimal places and negative sign, requiring the percent symbol at the end.
Hexadecimal Number
BeginnerValidates hexadecimal numbers with optional 0x prefix. Used in color codes, memory addresses, and low-level programming.
Binary Number
BeginnerMatches binary numbers (0s and 1s) with optional 0b prefix for standard binary notation.
Scientific Notation
IntermediateValidates numbers in scientific/exponential notation like 1.5e10 or -3.14E-5. Standard format for very large or small numbers.
Credit Card Number
AdvancedValidates Visa, Mastercard, Amex, and Discover card numbers by their prefix patterns and lengths. Does not verify Luhn checksum.
Date & Time
(10)Date (YYYY-MM-DD)
IntermediateValidates dates in ISO 8601 format (YYYY-MM-DD) with valid month (01-12) and day (01-31) ranges.
Date (MM/DD/YYYY)
IntermediateValidates dates in US format (MM/DD/YYYY). Ensures month is 01-12 and day is 01-31.
Date (DD/MM/YYYY)
IntermediateValidates dates in day-first format common in Europe and most of the world. Day 01-31, month 01-12.
Time (24-hour)
BeginnerValidates 24-hour time format (HH:MM or HH:MM:SS). Hours 00-23, minutes and seconds 00-59.
Time (12-hour)
BeginnerValidates 12-hour time with AM/PM indicator. Hours 1-12, minutes 00-59, with flexible spacing.
ISO 8601 DateTime
AdvancedValidates full ISO 8601 datetime strings with optional milliseconds and timezone offset (Z or +/-HH:MM).
Unix Timestamp
BeginnerMatches Unix timestamps in seconds (10 digits) or milliseconds (13 digits). Used universally in programming.
Relative Date
IntermediateMatches relative time expressions like "5 minutes ago" or "3 months from now" for human-readable timestamps.
Duration (HH:MM:SS)
BeginnerValidates time duration format with hours (any count), minutes (00-59), and seconds (00-59).
Cron Expression
AdvancedValidates standard 5-field cron expressions (minute, hour, day, month, weekday) with wildcards and ranges.
Text & Strings
(12)Username
BeginnerValidates usernames with letters, numbers, underscores, and hyphens. Length 3-20 characters.
Strong Password
IntermediateEnforces strong password policy: minimum 8 characters with at least one uppercase, lowercase, digit, and special character.
Slug (URL-friendly)
BeginnerValidates URL-friendly slugs with lowercase letters, numbers, and hyphens. No consecutive or trailing hyphens.
Hashtag
BeginnerExtracts hashtags starting with # followed by a letter and optional alphanumeric/underscore characters.
HTML Tag
IntermediateMatches opening and closing HTML tags with optional attributes. Useful for HTML manipulation and content extraction.
HTML Comments
BeginnerMatches HTML comments including multi-line content. Used for stripping comments during minification or processing.
Quoted String
AdvancedMatches single or double-quoted strings with proper escape handling. Handles escaped quotes within strings.
Markdown Link
IntermediateMatches Markdown inline links capturing both the display text and URL. Essential for Markdown-to-HTML converters.
Markdown Heading
BeginnerMatches Markdown headings H1-H6. Captures the level (number of #) and heading text.
Whitespace Trimmer
BeginnerMatches leading and trailing whitespace for trimming. Equivalent to the trim() method in most languages.
Duplicate Words
IntermediateDetects consecutively repeated words like "the the" or "is is". Useful for proofreading and text cleanup.
Sentence
BeginnerMatches sentences starting with a capital letter and ending with period, exclamation, or question mark.
Code & Programming
(12)JavaScript Variable
IntermediateMatches JavaScript variable declarations (const, let, var) and captures the variable name.
JavaScript Function
IntermediateMatches named function declarations in JavaScript, capturing the function name.
CSS Hex Color
BeginnerMatches 3 or 6-digit hex color codes. Commonly used to extract or validate colors from CSS stylesheets.
CSS Class Selector
BeginnerMatches CSS class selectors starting with a dot. Captures class names from stylesheets for analysis.
Python Import
IntermediateMatches Python import statements including `import` and `from...import` forms for dependency tracking.
SQL SELECT Statement
IntermediateMatches SQL SELECT queries extracting the table name from the FROM clause. Useful for query analysis and logging.
JSON Key-Value Pair
IntermediateMatches JSON key-value pairs with string, number, boolean, or null values. Useful for lightweight JSON processing.
TODO Comment
BeginnerExtracts TODO, FIXME, HACK, XXX, and BUG comments from source code for task tracking.
Semantic Version
IntermediateValidates semantic version strings (SemVer) with major.minor.patch and optional pre-release and build metadata.
Git Commit Hash
BeginnerMatches Git commit SHA hashes in both short (7 chars) and full (40 chars) formats.
Environment Variable
BeginnerMatches environment variable assignments in KEY=VALUE format with uppercase keys and underscores.
Import Path
IntermediateExtracts relative import paths from JavaScript/TypeScript import and require statements.
Security & Auth
(8)JWT Token
IntermediateValidates JWT (JSON Web Token) structure with three Base64URL-encoded segments separated by dots.
UUID (v4)
IntermediateValidates UUID version 4 format with the version nibble (4) and variant bits (8, 9, a, b) in correct positions.
API Key Pattern
AdvancedDetects potential API keys and tokens in source code. Used by security tools to prevent accidental secret exposure.
AWS Access Key
IntermediateMatches AWS access key IDs that always start with AKIA (long-term) or ASIA (temporary STS) followed by 16 uppercase alphanumeric characters.
Base64 Encoded String
BeginnerValidates Base64-encoded strings with proper character set and optional padding. Used in data transfer and encoding.
MD5 Hash
BeginnerMatches MD5 hash strings (32 hexadecimal characters). Used for checksums and file integrity verification.
SHA-256 Hash
BeginnerMatches SHA-256 hash strings (64 hexadecimal characters). Standard for modern cryptographic applications.
SSH Public Key
IntermediateMatches SSH public key format with algorithm prefix (rsa, ed25519, ecdsa) followed by Base64-encoded key data.
Data Formats
(10)JSON Object
BeginnerMatches JSON object patterns enclosed in curly braces. Simple detection pattern for JSON objects in text.
CSV Row
AdvancedMatches CSV rows handling quoted fields with escaped quotes. Essential for robust CSV file processing.
XML Tag with Content
IntermediateMatches XML elements with opening tag, content, and matching closing tag. Captures tag name and inner content.
YAML Key-Value
BeginnerMatches simple YAML key-value pairs. Useful for quick parsing of configuration files.
Log Entry (Common Log Format)
AdvancedParses Apache/Nginx Common Log Format entries, extracting IP, timestamp, method, path, status code, and bytes.
INI Section
BeginnerMatches INI file section headers enclosed in square brackets. Used for parsing configuration files.
TOML Key-Value
BeginnerMatches TOML configuration key-value pairs. Standard format for Rust (Cargo) and Python (pyproject) projects.
SQL Comment
IntermediateMatches both single-line (--) and multi-line (/* */) SQL comments for stripping or extracting documentation.
Docker Image Reference
IntermediateValidates Docker image references with optional registry, tag, and digest. Used in Dockerfiles and compose files.
File Path (Unix)
BeginnerMatches absolute Unix/Linux file paths starting with forward slash. Validates path component characters.
Web & HTML
(10)Email in Text
BeginnerExtracts email addresses from body text. Non-anchored version for finding emails within larger strings.
Image Tag (src)
IntermediateExtracts image source URLs from HTML img tags. Useful for web scraping, SEO image audits, and content migration.
Anchor Tag (href)
IntermediateExtracts URLs from HTML anchor tags. Essential for web crawlers, SEO tools, and broken link checkers.
Meta Tag Content
IntermediateExtracts content attribute values from HTML meta tags for SEO auditing and metadata analysis.
Inline CSS Style
BeginnerMatches inline CSS style attributes on HTML elements. Used for style extraction and converting inline styles to classes.
YouTube Video ID
IntermediateExtracts 11-character YouTube video IDs from various URL formats including standard, shortened, and embed URLs.
Twitter/X Handle
BeginnerMatches Twitter/X handles with @ prefix and 1-15 alphanumeric characters or underscores.
GitHub Repository URL
BeginnerExtracts owner and repository name from GitHub URLs. Used in dependency management and open source tooling.
CSS Media Query
IntermediateMatches CSS media query declarations for responsive design. Extracts breakpoints and conditions from stylesheets.
Data Attribute
BeginnerMatches HTML5 data attributes (data-*) and captures both the attribute name and value.
File & Path
(6)File Extension
BeginnerExtracts file extensions from filenames. Simple pattern for file type checking in upload forms.
Image File
BeginnerMatches common image file extensions including JPEG, PNG, GIF, SVG, WebP, BMP, ICO, and TIFF.
Video File
BeginnerMatches common video file extensions for upload validation and media file filtering.
File Path (Windows)
IntermediateValidates Windows file paths with drive letter, backslash separators, and restrictions on invalid characters.
MIME Type
IntermediateValidates MIME type format with standard top-level types and subtypes. Used in HTTP headers and file handling.
S3 Bucket URL
IntermediateMatches S3 protocol URLs with bucket name and optional path. Used in AWS CLI commands and data engineering.
Identity & Documents
(8)Social Security Number (US)
BeginnerMatches US Social Security Numbers in standard XXX-XX-XXXX format. Used for PII detection and data masking.
US Zip Code
BeginnerValidates US ZIP codes in 5-digit or ZIP+4 format. Essential for shipping and address validation forms.
US State Code
IntermediateMatches valid US state and DC two-letter abbreviations. Complete list of all 50 states plus District of Columbia.
UK Postcode
IntermediateValidates UK postcodes in various formats (A1 1AA, A11 1AA, AA1 1AA, etc.) with optional space.
Canadian Postal Code
BeginnerValidates Canadian postal codes in A1A 1A1 format alternating letters and digits with optional space.
Passport Number
BeginnerMatches common passport number formats with 1-2 letter prefix followed by 6-9 digits.
IBAN Number
AdvancedValidates International Bank Account Numbers with country code, check digits, bank code, and account number.
VIN (Vehicle Identification Number)
IntermediateValidates 17-character Vehicle Identification Numbers excluding I, O, and Q which can be confused with 1 and 0.
Advanced Patterns
(8)Balanced Parentheses
IntermediateMatches innermost balanced parentheses groups. Note: regex alone cannot match nested groups — use recursive patterns or parsers.
Lookahead (Positive)
AdvancedDemonstrates positive lookahead: matches a word only if followed by " is". Lookaheads check without consuming characters.
Lookbehind (Positive)
AdvancedDemonstrates positive lookbehind: matches numbers only when preceded by $. Extracts prices without the dollar sign.
Named Capture Groups
AdvancedDemonstrates named capture groups for readable regex. Access matches by name instead of index for clearer code.
Non-Greedy Matching
IntermediateShows non-greedy (lazy) matching with +? quantifier. Matches shortest possible string instead of longest.
Atomic Group Simulation
AdvancedSimulates atomic groups in JavaScript using lookahead with backreference. Prevents catastrophic backtracking.
Conditional with Alternation
IntermediateUses alternation within non-capturing group to match URLs with HTTP, HTTPS, or FTP protocols.
Recursive Pattern (Email List)
AdvancedMatches comma-separated email lists. Demonstrates pattern repetition for parsing delimited sequences.
What Are Regular Expressions?
Regular expressions (regex) are sequences of characters that define search patterns. They are used across virtually all programming languages for string matching, validation, search-and-replace, and data extraction. From validating email addresses to parsing log files, regex is an essential tool in every developer's toolkit.
Each pattern in our library includes an interactive live tester where you can paste your own text and see matches in real-time. We also provide code examples in JavaScript, Python, and Go so you can copy-paste directly into your project.