Skip to content
PwnDeck logoPwnDeck

Regex Pattern Library

A searchable library of 50+ common regex patterns. Browse by category, test against sample input, and copy patterns for email, URL, IP, dates, passwords, and more.

45 patterns

Email Address

Validates standard email addresses

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

Example: user@example.com

Phone (International)

E.164 international phone format

^\+?[1-9]\d{1,14}$

Example: +14155552671

Phone (US)

US phone number formats

^\(?\d{3}\)?[-\s.]?\d{3}[-\s.]?\d{4}$

Example: (415) 555-2671

URL (HTTP/HTTPS)

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

Validates IPv4 addresses

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

Example: 192.168.1.1

IPv6 Address

Full IPv6 address format

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

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

Domain Name

Valid domain names

^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$

Example: sub.example.com

MAC Address

MAC address with colons or dashes

^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$

Example: 00:1B:44:11:3A:B7

Slug (URL-friendly)

URL-friendly slug format

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

Example: my-blog-post

Credit Card (generic)

Visa, Mastercard, 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})$

Example: 4111111111111111

SSN (US)

US Social Security Number format

^\d{3}-\d{2}-\d{4}$

Example: 123-45-6789

Strong Password

Min 8 chars, upper, lower, digit, special

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

Example: Str0ng@Pass

JWT Token

JSON Web Token format

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

Example: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxIn0.sig

API Key (hex)

Hex API key 32-64 characters

^[a-fA-F0-9]{32,64}$

Example: a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4

Date (YYYY-MM-DD)

ISO 8601 date format

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

Example: 2024-01-15

Date (MM/DD/YYYY)

US date format

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

Example: 01/15/2024

Time (24h)

24-hour time format

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

Example: 14:30:00

ISO 8601 DateTime

Full ISO 8601 datetime

^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$

Example: 2024-01-15T14:30:00Z

HTML Tag

Match paired HTML tags

<([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>.*?<\/\1>

Example: <div>content</div>

Hex Color

3 or 6 digit hex color

^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Example: #FF5733

Semantic Version

SemVer format

^\d+\.\d+\.\d+(?:-[\da-zA-Z-]+(?:\.[\da-zA-Z-]+)*)?(?:\+[\da-zA-Z-]+)?$

Example: 1.2.3-beta.1

UUID v4

UUID version 4 format

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

Example: 123e4567-e89b-42d3-a456-426614174000

JSON Key-Value

Simple JSON string key-value pairs

"([^"]+)"\s*:\s*"([^"]*)"

Example: "key": "value"

CSS Selector (class)

CSS class selectors

\.[a-zA-Z_][a-zA-Z0-9_-]*

Example: .my-class

Import Statement (JS)

JavaScript/TypeScript import

^import\s+.*\s+from\s+['"]([^'"]+)['"]

Example: import x from 'module'

Whitespace Only

String with only whitespace

^\s+$

Example:

No Whitespace

String without whitespace

^\S+$

Example: nospaces

Alphanumeric

Only letters and numbers

^[a-zA-Z0-9]+$

Example: abc123

Contains No Digits

No digits allowed

^[^\d]+$

Example: Hello World!

Repeated Words

Find repeated consecutive words

\b(\w+)\s+\1\b

Example: the the

Markdown Link

Markdown hyperlink syntax

\[([^\]]+)\]\(([^)]+)\)

Example: [text](url)

Hashtag

Social media hashtag

#[a-zA-Z0-9_]+

Example: #coding

Username (@mention)

Twitter/social media mention

@[a-zA-Z0-9_]{1,15}

Example: @username

Integer

Positive or negative integer

^-?\d+$

Example: -42

Decimal Number

Decimal floating point

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

Example: 3.14

Scientific Notation

Scientific notation format

^-?\d+\.?\d*[eE][+-]?\d+$

Example: 1.5e10

Percentage

Percentage value

^\d+(?:\.\d+)?%$

Example: 99.5%

Currency (USD)

US dollar format

^\$\d{1,3}(?:,\d{3})*(?:\.\d{2})?$

Example: $1,234.56

File Extension

Extract file extension

\.[a-zA-Z0-9]+$

Example: document.pdf

Image File

Common image extensions

\.(?:jpg|jpeg|png|gif|bmp|svg|webp)$

Example: photo.jpg

File Path (Unix)

Unix-style file path

^\/(?:[^\/]+\/)*[^\/]+$

Example: /usr/local/bin/node

File Path (Windows)

Windows file path

^[a-zA-Z]:\\(?:[^\\]+\\)*[^\\]+$

Example: C:\Users\file.txt

Base64 String

Base64 encoded string

^[A-Za-z0-9+\/]+={0,2}$

Example: SGVsbG8gV29ybGQ=

MD5 Hash

32-char hex MD5

^[a-fA-F0-9]{32}$

Example: d41d8cd98f00b204e9800998ecf8427e

SHA-256 Hash

64-char hex SHA-256

^[a-fA-F0-9]{64}$

Example: e3b0c44298fc1c149afbf4c8996fb924...

Advertisement

How to Use the Regex Pattern Library

  1. Search for patterns by name or description using the search bar.
  2. Filter by category: Contact, Network, Security, Date, Code, Text, Numbers, Files, Encoding.
  3. Optionally enter a test input to see which patterns match.
  4. Click the copy button to copy any regex pattern.
  5. Each pattern includes an example string for quick reference.

About Regex Pattern Library

Regular expressions are powerful pattern-matching tools used across programming languages for text validation, search, and extraction. This library provides 50+ pre-built, tested regex patterns organized by category. Each pattern includes a description, example input, and the ability to test against your own input. Categories cover common validation needs like email addresses, URLs, IP addresses, phone numbers, dates, passwords, file paths, and code patterns. All patterns use standard regex syntax compatible with JavaScript, Python, and most other languages.

Advertisement

Frequently Asked Questions

Most patterns cover common cases and are suitable for basic validation. For production use, especially with security-sensitive data like email addresses, consider using established validation libraries that handle edge cases and internationalization.

The patterns use standard regex syntax that works in JavaScript, Python, PHP, Java, Go, and most modern languages. Some features like lookaheads may have limited support in older regex engines.