Regex Library
Browse, search, and test common regex patterns — copy with one click.
Email Address
Validates standard email addresses
URL
Matches HTTP/HTTPS URLs
Phone (International)
E.164 international phone format
Phone (US)
US phone numbers with optional formatting
IPv4 Address
Validates IPv4 addresses (0.0.0.0 - 255.255.255.255)
IPv6 Address
Matches full IPv6 addresses
MAC Address
Matches MAC addresses
Credit Card
Visa, Mastercard, Amex, Discover
Hex Color
Matches 3 or 6 digit hex colors
HTML Tags
Matches opening and closing HTML tags
Quoted String
Matches single or double quoted strings
Slug
URL-friendly slug format
Whitespace Trim
Matches leading/trailing whitespace
Duplicate Words
Finds repeated consecutive words
Integer
Positive or negative integers
Decimal Number
Decimal/float numbers
Date (YYYY-MM-DD)
ISO 8601 date format
Date (MM/DD/YYYY)
US date format
Time (HH:MM)
24-hour time format
Currency
US dollar amounts
Strong Password
Min 8 chars, upper, lower, digit, special
UUID v4
UUID version 4 format
JWT Token
JSON Web Token format
Base64
Base64 encoded string
JS Variable
Valid JavaScript variable name
Semver
Semantic versioning (major.minor.patch)
Import Statement
ES module import statements
CSS Class
CSS class selectors
Single-line Comment
JS/TS single-line comments
What It Does
A curated, searchable collection of production-ready regular expressions organized by category. Find the pattern you need, test it against your own input in the live tester, and copy it to your clipboard. No need to write complex regex from scratch or hunt through documentation.
Pattern Categories
- Validation — Email, URL, phone number, IPv4/IPv6, credit card number
- Strings & Text — HTML tags, quoted strings, URL slugs, whitespace normalization
- Numbers & Dates — Integers, floats, ISO 8601 dates, currency amounts
- Security — Strong passwords, UUID v4, JWT tokens, Base64 strings
- Programming — Variable names, semantic versioning, import/require statements
Regex Quick Reference
.Any char\dDigit\wWord char\sWhitespace^Start$End\bWord boundary*0++1+?0 or 1{n,m}n to m times[abc]Character class[^abc]Negated class(abc)Capture group(?:abc)Non-capturing groupa|bAlternation(?=abc)Lookahead
Tips for Using Regex in Production
- Anchor patterns with
^and$for validation — otherwise a pattern can match a substring of invalid input. - Avoid catastrophic backtracking — nested quantifiers like
(a+)+can hang on adversarial input (ReDoS attack). - Use named capture groups (
(?<year>\d4)) for readability in complex extraction patterns. - Always validate email addresses by sending a confirmation message — no regex fully covers RFC 5322.
Frequently Asked Questions
- What regex patterns are included in this library?
- The library covers five categories: Validation (email, URL, phone number, IP address, credit card), Strings and Text (HTML tags, quoted strings, slugs, whitespace), Numbers and Dates (integers, floats, ISO dates, currency), Security (strong passwords, UUID, JWT, Base64), and Programming (variable names, semantic version, import statements).
- How do I use regex flags like g, i, and m?
- Flags modify matching behaviour. g (global) finds all matches rather than stopping at the first. i (case-insensitive) ignores letter case. m (multiline) makes ^ and $ match the start and end of each line instead of the whole string. s (dotAll) makes the dot match newlines. Flags are appended after the closing slash: /pattern/gim.
- What is the difference between greedy and lazy quantifiers?
- Greedy quantifiers (*, +, ?) match as much as possible. Lazy quantifiers (*?, +?, ??) match as little as possible. For example, <.*> applied to <b>bold</b> greedily matches the entire string, while <.*?> matches only <b> and then </b> separately. Use lazy quantifiers when extracting tags or quoted strings.
- How do I validate an email address with regex?
- A production-grade email regex is complex — RFC 5322 allows many unusual formats. A pragmatic pattern that covers the vast majority of real addresses is /^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$/. For critical applications, validate by sending a confirmation email rather than relying solely on regex.
- Are these regex patterns compatible with JavaScript, Python, and other languages?
- Most patterns use PCRE-compatible syntax that works in JavaScript, Python (re module), PHP, Java, and Go. Some minor differences exist — for example, Python uses (?P<name>) for named groups while JavaScript uses (?<name>). Always test a pattern in your target language before shipping it to production.