R

TestRegex

Pattern Library

A curated collection of production-ready regular expressions. Search, filter, and copy patterns for your next project.

Validation

Email Address

Validate email addresses with RFC-compliant regex pattern.

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

Password Strength

At least 8 chars, 1 uppercase, 1 lowercase, 1 number, 1 special char.

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

IPv4 Address

Matches valid IPv4 addresses.

^(?:(?: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]?)$
Validation

UUID v4

Matches a version 4 UUID.

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

Date (ISO 8601)

Matches dates in YYYY-MM-DD format.

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

URL Slug

Matches valid URL slugs (kebab-case).

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

Hex Color Code

Matches hex color codes (#FFF or #FFFFFF).

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

HTML Tag

Matches opening and closing HTML tags.

<[^>]+>
Web

Twitter Handle

Matches a Twitter handle (username).

^@?(\w){1,15}$
Data

Simple JSON Object

Matches a simple flat JSON object (basic approximation).

\{\s*"[^"]+"\s*:\s*(?:"[^"]+"|\d+|true|false|null)\s*\}
Data

CSV Field

Matches a CSV field, handling quotes.

(?:^|,)(?:"([^"]*(?:""[^"]*)*)"|([^",]*))
Text

Duplicate Words

Finds duplicate words in a sentence.

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

Trailing Whitespace

Matches whitespace at the end of lines.

[ \t]+$
Text

Split CamelCase

Matches the position before capital letters to split CamelCase.

(?<=[a-z])(?=[A-Z])
Validation

Credit Card (Simple)

Matches major credit cards (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})$
Validation

US SSN

Matches US Social Security Numbers (XXX-XX-XXXX).

^(?!000|666|9\d\d)\d{3}-(?!00)\d{2}-(?!0000)\d{4}$
Validation

US Phone Number

Matches US phone numbers in various formats.

^\(?([2-9][0-8][0-9])\)?[-. ]?([2-9][0-9]{2})[-. ]?([0-9]{4})$
Validation

IPv6 Address

Matches standard IPv6 addresses.

^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$
Validation

MAC Address

Matches identifiers assigned to network interfaces.

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

Semantic Versioning

Matches SemVer 2.0.0 strings.

^v?(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-]+)*))?$
DevOps

Docker Image

Matches typical Docker image names.

^(?:(?=[^:\/]{1,253})(?!-)[a-z0-9-]{1,63}(?<!-)(?:\.(?!-)[a-z0-9-]{1,63}(?<!-))*(?::[0-9]{1,5})?/)?((?![._-])(?:[a-z0-9._-]*)(?<![._-])(?:\/(?![._-])[a-z0-9._-]*(?<![._-]))*)(?::(?![.-])[a-zA-Z0-9_.-]{1,128})?$
DevOps

AWS ARN

Matches Amazon Resource Names.

^arn:(?:aws|aws-cn|aws-us-gov|aws-iso|aws-iso-b):[a-z0-9-]*:[a-z0-9-]*:[0-9]{12}:[a-zA-Z0-9-_/]+$
DevOps

Cron Expression

Matches logical parts of a standard Cron schedule.

^(\*|([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])|\*\/([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])) (\*|([0-9]|1[0-9]|2[0-3])|\*\/([0-9]|1[0-9]|2[0-3])) (\*|([1-9]|1[0-9]|2[0-9]|3[0-1])|\*\/([1-9]|1[0-9]|2[0-9]|3[0-1])) (\*|([1-9]|1[0-2])|\*\/([1-9]|1[0-2])) (\*|([0-6])|\*\/([0-6]))$
Security

MD5 Hash

Matches a 32-character hexadecimal MD5 hash.

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

SHA-256 Hash

Matches a 64-character hexadecimal SHA-256 hash.

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

JWT Token

Matches the structure of a JSON Web Token.

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

Base64 String

Matches valid Base64 encoded strings.

^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$
Numbers

Currency (USD)

Matches a price in USD, with optional cents.

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

Time (24h)

Matches time in HH:MM format (24-hour).

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

Percentage

Matches a percentage value (0-100), optional decimals.

^(?:100(?:\.0+)?|\d{1,2}(?:\.\d+)?|0(?:\.\d+)?)\%?$
Numbers

Lat/Long Coordinates

Matches decimal latitude and longitude pairs.

^[-+]?([1-8]?\d(\.\d+)?|90(\.0+)?),\s*[-+]?(180(\.0+)?|((1[0-7]\d)|([1-9]?\d))(\.\d+)?)$
Files

Image File Extension

Matches common image file extensions.

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

Windows File Path

Matches a Windows file path (drive letter + path).

^[a-zA-Z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*$
Files

Linux/Unix Path

Matches an absolute path on Linux/Unix systems.

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

YouTube Video ID

Matches the 11-character YouTube video identifier.

^[a-zA-Z0-9_-]{11}$