Regex Library

Searchable collection of common regex patterns

Showing 46 patterns
Email Address
email-urls

Matches standard email addresses

^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Match user@example.com
No Match user@.com
URL with Protocol
email-urls

Matches HTTP/HTTPS URLs

^https?:\/\/(www\.)?[a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$
Match https://example.com/path
No Match ftp://file.txt
Domain Name
email-urls

Matches domain names without protocol

^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$
Match sub.example.com
No Match -invalid.com
Slug (URL-friendly)
email-urls

Matches URL slugs

^[a-z0-9]+(-[a-z0-9]+)*$
Match my-blog-post
No Match My Blog Post
Integer
numbers

Matches positive or negative integers

^-?\d+$
Match -42
No Match 3.14
Decimal Number
numbers

Matches decimal numbers

^-?\d+\.\d+$
Match 3.14
No Match 42
Hex Color Code
numbers

Matches hex color codes

^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$
Match #ff5733
No Match #xyz
Binary Number
numbers

Matches binary strings

^[01]+$
Match 10110
No Match 102
Octal Number
numbers

Matches octal numbers

^0[0-7]+$
Match 0755
No Match 089
Scientific Notation
numbers

Matches numbers in scientific notation

^-?\d+(\.\d+)?[eE][+-]?\d+$
Match 1.5e10
No Match 1.5x10
Date (YYYY-MM-DD)
dates

Matches ISO 8601 date format

^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
Match 2024-01-15
No Match 2024-13-01
Date (MM/DD/YYYY)
dates

Matches US date format

^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$
Match 01/15/2024
No Match 13/01/2024
Date (DD/MM/YYYY)
dates

Matches European date format

^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$
Match 15/01/2024
No Match 32/01/2024
Time (HH:MM:SS)
dates

Matches 24-hour time format

^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$
Match 14:30:00
No Match 25:00:00
ISO 8601 DateTime
dates

Matches ISO 8601 datetime

^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$
Match 2024-01-15T14:30:00Z
No Match 2024-01-15 14:30
US Phone Number
phone

Matches US phone numbers

^\(?\d{3}\)?[-\s]?\d{3}[-\s]?\d{4}$
Match (555) 123-4567
No Match 123-45-6789
International Phone
phone

Matches E.164 international phone format

^\+?[1-9]\d{1,14}$
Match +14155552671
No Match +0123
UK Phone Number
phone

Matches UK phone numbers

^(\+44|0)\d{10}$
Match +447911123456
No Match +44123
Strong Password
passwords

At least 8 chars: uppercase, lowercase, digit, special

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Match Str0ng!Pass
No Match weakpass
Medium Password
passwords

At least 6 chars: uppercase, lowercase, digit

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[A-Za-z\d]{6,}$
Match Pass12
No Match pass
PIN Code (4-6 digits)
passwords

Matches 4 to 6 digit PIN codes

^\d{4,6}$
Match 1234
No Match 123
Unix File Path
file-paths

Matches Unix/Linux file paths

^\/([a-zA-Z0-9._-]+\/)*[a-zA-Z0-9._-]+$
Match /usr/local/bin/node
No Match C:\folder
Windows File Path
file-paths

Matches Windows file paths

^[a-zA-Z]:\\([^\\/:*?"<>|]+\\)*[^\\/:*?"<>|]+$
Match C:\Users\file.txt
No Match /usr/local
File Extension
file-paths

Matches file extensions

\.[a-zA-Z0-9]{1,10}$
Match file.txt
No Match noextension
Image File
file-paths

Matches common image file extensions

\.(jpg|jpeg|png|gif|bmp|svg|webp)$
Match photo.jpg
No Match doc.pdf
HTML Tag
html-xml

Matches paired HTML tags with content

<([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>.*?<\/\1>
Match <div>hello</div>
No Match <br/>
Self-closing Tag
html-xml

Matches self-closing HTML/XML tags

<[a-zA-Z][a-zA-Z0-9]*\b[^>]*\/>
Match <br/>
No Match <div></div>
HTML Comment
html-xml

Matches HTML comments

<!--[\s\S]*?-->
Match <!-- comment -->
No Match // comment
HTML Entity
html-xml

Matches HTML entities

&[a-zA-Z]+;|&#\d+;|&#x[a-fA-F0-9]+;
Match &amp;
No Match & amp
IPv4 Address
network

Matches IPv4 addresses

^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$
Match 192.168.1.1
No Match 256.1.1.1
IPv6 Address
network

Matches full IPv6 addresses

^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$
Match 2001:0db8:85a3:0000:0000:8a2e:0370:7334
No Match 192.168.1.1
MAC Address
network

Matches MAC addresses

^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$
Match 00:1B:44:11:3A:B7
No Match 00:1B:44
Port Number
network

Matches valid port numbers (1-65535)

^([1-9]\d{0,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$
Match 8080
No Match 70000
Subnet Mask (CIDR)
network

Matches CIDR notation

^\/(3[0-2]|[12]?\d)$
Match /24
No Match /33
Visa Card
credit-cards

Matches Visa card numbers

^4[0-9]{12}(?:[0-9]{3})?$
Match 4111111111111111
No Match 5111111111111111
Mastercard
credit-cards

Matches Mastercard numbers

^5[1-5][0-9]{14}$
Match 5500000000000004
No Match 4111111111111111
American Express
credit-cards

Matches American Express card numbers

^3[47][0-9]{13}$
Match 378282246310005
No Match 4111111111111111
Any Credit Card
credit-cards

Matches Visa, MC, Amex, Discover

^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})$
Match 4111111111111111
No Match 1234567890
CVV
credit-cards

Matches 3 or 4 digit CVV codes

^\d{3,4}$
Match 123
No Match 12
UUID v4
identifiers

Matches UUID version 4

^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
Match 550e8400-e29b-41d4-a716-446655440000
No Match 550e8400
SSN (US)
identifiers

Matches US Social Security Numbers

^(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}$
Match 123-45-6789
No Match 000-00-0000
Hex String
identifiers

Matches hexadecimal strings

^[0-9a-fA-F]+$
Match deadbeef
No Match ghijkl
MD5 Hash
identifiers

Matches MD5 hash strings

^[a-fA-F0-9]{32}$
Match d41d8cd98f00b204e9800998ecf8427e
No Match abc123
SHA-256 Hash
identifiers

Matches SHA-256 hash strings

^[a-fA-F0-9]{64}$
Match e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
No Match short
JSON Web Token
identifiers

Matches JWT token structure

^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+$
Match eyJhbGci.eyJzdWIi.SflKxwRJ
No Match not.a.jwt.token
Semantic Version
identifiers

Matches semantic versioning (semver)

^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-[\da-zA-Z-]+(\.[\da-zA-Z-]+)*)?(\+[\da-zA-Z-]+(\.[\da-zA-Z-]+)*)?$
Match 1.2.3-beta.1
No Match 1.2

Regex Library

Searchable collection of common regex patterns

Features

  • 40+ curated regex patterns organized by category
  • Search and filter by name, description, or regex
  • Click-to-copy any regex pattern
  • Example matches and non-matches for each pattern

How to use

  1. Browse categories or use the search box to find patterns.
  2. Review the regex pattern, description, and examples.
  3. Click the copy button to copy the regex to your clipboard.

Tips & Best Practices

  • Use the search box to quickly find patterns by keyword.
  • Click the copy button to get the regex ready for your code.
  • Test patterns against your own data before using in production.
  • Combine multiple patterns for complex validation scenarios.
  • Remember to escape backslashes when using in string literals.

FAQ

Are these regex patterns production-ready?

These patterns cover common use cases and are suitable for most applications. For critical validation, consider edge cases specific to your requirements.

What regex flavor are these patterns?

These patterns use JavaScript-compatible regex syntax, which works across most modern programming languages with minimal modifications.

Is this tool free to use?

Yes, this tool is completely free with no registration required. There are no usage limits, no premium tiers, and no hidden costs.

Is my data safe and private?

Absolutely. All processing happens locally in your browser. No data is ever sent to our servers or any third party.

Does this tool work offline?

Once the page is loaded, the tool works entirely in your browser without requiring an internet connection.