T
DataToolings

Regex Library — Common Regular Expressions Reference

Browse a curated library of common regular expressions for email, URL, phone, date, and more. Copy patterns instantly. Free regex reference tool.

26 patterns

Email Address
validation
email

Validates a standard email address format

^[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}$

Example: user@example.com

URL (http/https)
validation
url

Matches http and https URLs

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)

Example: https://example.com/path?q=1

IPv4 Address
network
validation

Validates an IPv4 address (0.0.0.0 – 255.255.255.255)

^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$

Example: 192.168.1.1

IPv6 Address
network
validation

Matches a full IPv6 address

^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$

Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334

Phone (US)
validation
phone

Matches US phone numbers in various formats

^(\+1)?[\s.-]?\(?[0-9]{3}\)?[\s.-]?[0-9]{3}[\s.-]?[0-9]{4}$

Example: (555) 123-4567

Date (YYYY-MM-DD)
date
validation

Validates ISO 8601 date format

^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$

Example: 2024-03-15

Date (MM/DD/YYYY)
date
validation

Validates US date format

^(0[1-9]|1[0-2])\/(0[1-9]|[12]\d|3[01])\/\d{4}$

Example: 03/15/2024

Time (HH:MM)
date
validation

Validates 24-hour time format

^([01]?[0-9]|2[0-3]):[0-5][0-9]$

Example: 14:30

Credit Card
validation
payment

Matches Visa, Mastercard, Amex, Discover card numbers

^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|6(?:011|5[0-9]{2})[0-9]{12})$

Example: 4111111111111111

ZIP Code (US)
validation
address

Validates US ZIP codes (5-digit or ZIP+4)

^\d{5}(-\d{4})?$

Example: 90210 or 90210-1234

Hex Color
css
color

Matches 3 or 6 digit hex color codes

^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$

Example: #FF5733 or #F53

RGB Color
css
color

Matches CSS rgb() color values

^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$

Example: rgb(255, 87, 51)

Slug
url
validation

Validates URL-friendly slugs

^[a-z0-9]+(?:-[a-z0-9]+)*$

Example: my-blog-post-title

Username
validation
auth

Alphanumeric username, 3–20 chars, underscores allowed

^[a-zA-Z0-9_]{3,20}$

Example: john_doe123

Strong Password
validation
auth
security

Min 8 chars, uppercase, lowercase, digit, special char

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$

Example: P@ssw0rd!

JWT Token
auth
security

Matches a JSON Web Token (3 base64url parts)

^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$

Example: eyJ...header.payload.signature

UUID v4
validation
id

Validates a UUID v4 string

^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$

Example: 550e8400-e29b-41d4-a716-446655440000

Semantic Version
validation
versioning

Validates semver strings like 1.2.3 or 1.0.0-alpha.1

^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$

Example: 1.2.3 or 2.0.0-beta.1

HTML Tag
html
parsing

Matches HTML tags with content (non-void elements)

<([a-z][a-z0-9]*)\b[^>]*>(.*?)<\/\1>

Example: <div class="foo">content</div>

Markdown Link
markdown
parsing

Matches Markdown hyperlinks

\[([^\[]+)\]\((https?://[^\)]+)\)

Example: [Google](https://google.com)

File Extension
files
validation

Matches common file extensions

\.(jpg|jpeg|png|gif|webp|svg|pdf|doc|docx|xls|xlsx|zip|tar|gz)$

Example: document.pdf

IP + Port
network
validation

Matches IPv4:port combinations

^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$

Example: 192.168.1.1:8080

Git Commit Hash
git
validation

Matches short (7) or full (40) git commit hashes

^[0-9a-f]{7,40}$

Example: a1b2c3d or a1b2c3d4e5f6...

Whitespace Only
string
validation

Matches strings that are empty or contain only whitespace

^\s*$

Example: (spaces only)

Integer
number
validation

Matches positive or negative integers

^-?\d+$

Example: 42 or -17

Decimal Number
number
validation

Matches integers and decimal numbers

^-?\d+(\.\d+)?$

Example: 3.14 or -2.5

Related Developer Tools

What is Regex Library?

Regex Library is a free, searchable collection of common regular expressions for developers. Browse patterns for email, URL, phone, date, color, security, and more. Copy any pattern with one click and use it directly in your code.

How to Use Regex Library

  1. Search by name, description, or tag using the search box
  2. Filter by category using the tag buttons
  3. Click the copy button on any pattern to copy it to your clipboard
  4. Paste the pattern into your code or use the Regex Tester to test it

Features

  • 26 curated patterns covering common use cases
  • Search by name, description, or tag
  • Filter by category: validation, auth, network, date, CSS, and more
  • One-click copy for each pattern

FAQ

Are these patterns production-ready?

These patterns cover the most common cases but may need adjustment for edge cases in your specific use case. Always test patterns against your actual data before deploying to production.

How do I test a pattern?

Copy the pattern and paste it into the Regex Tester tool on this site to test it against your own input strings.

What regex flavor do these use?

All patterns use JavaScript-compatible regex syntax, which is compatible with most modern programming languages including Python, Java, and Go with minor adjustments.