Regex Pattern Library

111 patterns across 10 categories — with live tester and one-click copy

Email & Web

Email Address

Matches a standard email address.

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

Example: hello@example.com

Email & Web

Email Address (Strict)

RFC 5322 compliant email address validation.

/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~\-]+@[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?)*$/i

Example: user.name+tag@sub.domain.co.uk

Email & Web

HTTP/HTTPS 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()@:%_+.~#?&/=]*)/gi

Example: https://www.example.com/path?query=1

Email & Web

URL (any protocol)

Matches any URL with a protocol prefix (http, ftp, mailto, etc.).

/[a-zA-Z][a-zA-Z0-9+\-.]*:\/\/[^\s/$.?#].[^\s]*/gi

Example: ftp://files.example.com/resource

Email & Web

Domain Name

Matches a domain name (with or without subdomains).

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

Example: sub.example.co.uk

Email & Web

URL Slug

Matches a valid URL slug (lowercase letters, numbers, hyphens).

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

Example: my-page-title-123

Email & Web

Query String Parameter

Extracts key=value pairs from a URL query string.

/[?&]([^=#]+)=([^&#]*)/g

Example: ?page=2&sort=asc&filter=active

HTML & Code

HTML Tag

Matches an opening HTML tag.

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

Example: <div class="container">

HTML & Code

HTML Closing Tag

Matches an HTML closing tag.

/<\/([a-zA-Z][a-zA-Z0-9]*)>/gi

Example: </div>

HTML & Code

HTML Self-Closing Tag

Matches self-closing HTML tags like <br />, <img />.

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

Example: <img src="photo.jpg" alt="photo" />

HTML & Code

HTML Comment

Matches HTML comments including multiline.

/<!--[\s\S]*?-->/g

Example: <!-- This is a comment -->

HTML & Code

HTML Attribute

Matches HTML attribute key="value" pairs.

/([a-zA-Z][\w-]*)=["']([^"']*)["']/g

Example: class="main-nav" id="header"

HTML & Code

CSS Hex Colour

Matches 3 or 6 digit CSS hex colour values.

/#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\b/g

Example: #ff5733 and #fff

HTML & Code

CSS rgb() / rgba()

Matches CSS rgb() and rgba() colour functions.

/rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}(?:\s*,\s*[0-9.]+)?\s*\)/gi

Example: rgb(255, 87, 51) or rgba(255, 87, 51, 0.5)

HTML & Code

CSS Class Selector

Matches CSS class selectors.

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

Example: .container .nav-item

Phone

US Phone Number

Matches US phone numbers in various formats.

/(?:\+1\s?)?\(?\d{3}\)?[\s.\-]?\d{3}[\s.\-]?\d{4}/g

Example: (555) 123-4567 or +1 555.123.4567

Phone

UK Phone Number

Matches UK phone numbers including +44 prefix.

/(?:(?:\+44)|(?:0))(?:\s?\d){9,10}/g

Example: +44 7911 123456 or 07911 123456

Phone

International Phone (E.164)

Matches E.164 format international phone numbers.

/\+[1-9]\d{1,14}/g

Example: +447911123456

Phone

Generic Phone Number

Loosely matches phone numbers of 7–20 digits with common separators.

/[+]?[\d\s.\-()]{7,20}/g

Example: +1 (800) 555-0100

Phone

Phone — Digits Only

Matches a raw phone number with only digits (7–15).

/^\d{7,15}$/

Example: 5551234567

Dates & Time

ISO 8601 Date

Matches ISO 8601 formatted dates (YYYY-MM-DD).

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

Example: 2024-03-15

Dates & Time

US Date (MM/DD/YYYY)

Matches US format dates (MM/DD/YYYY).

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

Example: 03/15/2024

Dates & Time

EU Date (DD/MM/YYYY)

Matches European format dates (DD/MM/YYYY).

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

Example: 15/03/2024

Dates & Time

Time (24-hour)

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

/([01]\d|2[0-3]):([0-5]\d)(?::([0-5]\d))?/g

Example: 14:30 or 09:05:22

Dates & Time

Time (12-hour AM/PM)

Matches 12-hour time format with AM/PM.

/(0?[1-9]|1[0-2]):([0-5]\d)(?::([0-5]\d))?\s?[AaPp][Mm]/g

Example: 2:30 PM or 11:59:59am

Dates & Time

ISO 8601 DateTime

Matches full ISO 8601 datetime strings including timezone.

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

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

Dates & Time

Unix Timestamp

Matches a 10-digit Unix timestamp (seconds since epoch).

/\b1[0-9]{9}\b/g

Example: 1710500000

Dates & Time

Year (4-digit)

Matches 4-digit years from 1900 to 2099.

/\b(19|20)\d{2}\b/g

Example: 1995 or 2024

Numbers

Integer

Matches positive or negative whole numbers.

/-?\b\d+\b/g

Example: 42, -7, 1000

Numbers

Decimal / Float

Matches decimal numbers (floating point).

/-?\b\d+\.\d+\b/g

Example: 3.14, -0.5, 100.00

Numbers

Number with Thousand Separators

Matches numbers formatted with commas as thousand separators.

/\b\d{1,3}(?:,\d{3})*(?:\.\d+)?\b/g

Example: 1,234,567 or 1,000.50

Numbers

Currency (USD/GBP/EUR)

Matches currency amounts prefixed with $, £, or €.

/[$£€]\s?\d{1,3}(?:,\d{3})*(?:\.\d{2})?/g

Example: $1,299.99 or £45.00

Numbers

Percentage

Matches percentage values.

/\b\d+(?:\.\d+)?\s?%/g

Example: 99%, 12.5 %

Numbers

Hexadecimal Number

Matches hexadecimal literals with 0x prefix.

/\b0[xX][0-9a-fA-F]+\b/g

Example: 0xFF, 0x1a2b

Numbers

Binary Number

Matches binary literals with 0b prefix.

/\b0[bB][01]+\b/g

Example: 0b1010, 0B11001100

Numbers

Octal Number

Matches octal literals with 0o prefix.

/\b0[oO][0-7]+\b/g

Example: 0o755, 0O644

Numbers

Scientific Notation

Matches numbers in scientific notation.

/-?\d+(?:\.\d+)?[eE][+-]?\d+/g

Example: 1.5e10, -3.2E-4

Numbers

Positive Integer Only

Validates a string is a positive integer (no zero, no negatives).

/^[1-9]\d*$/

Example: 1, 42, 100

Passwords

Strong Password

Requires at least 8 chars, uppercase, lowercase, digit, and special character.

/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]).{8,}$/

Example: MyP@ssw0rd!

Passwords

Medium Password

Requires at least 6 characters with at least one letter and one digit.

/^(?=.*[a-zA-Z])(?=.*\d).{6,}$/

Example: hello1, abc123

Passwords

Password (No Spaces)

Ensures password has no spaces and is at least 8 characters.

/^\S{8,}$/

Example: NoSpaces99

Passwords

PIN (4 digits)

Validates a 4-digit numeric PIN.

/^\d{4}$/

Example: 1234

Passwords

PIN (6 digits)

Validates a 6-digit numeric PIN or OTP.

/^\d{6}$/

Example: 123456

Files & Paths

File Extension

Matches the file extension at the end of a filename.

/\.[a-zA-Z0-9]{1,10}$/i

Example: document.pdf, image.jpeg

Files & Paths

Filename with Extension

Matches a filename including its extension.

/[\w,\s\-]+\.[A-Za-z]{2,6}/g

Example: my-document.pdf

Files & Paths

Unix/Linux File Path

Matches Unix/Linux absolute file paths.

/(\/[a-zA-Z0-9._\-]+)+\/?/g

Example: /var/www/html/index.html

Files & Paths

Windows File Path

Matches Windows absolute file paths.

/[A-Za-z]:\\(?:[^\\/:*?"<>|\r\n]+\\)*[^\\/:*?"<>|\r\n]*/g

Example: C:\Users\John\Documents\file.txt

Files & Paths

Image File Extension

Matches common image file extensions.

/\.(jpg|jpeg|png|gif|bmp|svg|webp|tiff?|ico)$/i

Example: photo.jpg, icon.svg

Files & Paths

Video File Extension

Matches common video file extensions.

/\.(mp4|mkv|avi|mov|wmv|flv|webm|m4v|mpeg|mpg)$/i

Example: video.mp4, movie.mkv

Files & Paths

Audio File Extension

Matches common audio file extensions.

/\.(mp3|wav|flac|aac|ogg|wma|m4a|opus)$/i

Example: music.mp3, podcast.flac

Files & Paths

Document File Extension

Matches common document file extensions.

/\.(pdf|doc|docx|xls|xlsx|ppt|pptx|odt|ods|odp|txt|csv|rtf)$/i

Example: report.pdf, spreadsheet.xlsx

Text

Whitespace (1 or more)

Matches one or more whitespace characters (spaces, tabs, newlines).

/\s+/g

Example: hello world

Text

Empty Lines

Matches empty or whitespace-only lines.

/^\s*$/gm

Example: line1 line4

Text

Word

Matches individual words (letters only).

/\b[a-zA-Z]+\b/g

Example: Hello world

Text

Alphanumeric Word

Matches words containing letters and/or numbers.

/\b[a-zA-Z0-9]+\b/g

Example: word123 or hello

Text

Sentence

Matches a sentence starting with uppercase and ending with punctuation.

/[A-Z][^.!?]*[.!?]/g

Example: Hello world. How are you?

Text

Repeated Words

Detects consecutive duplicate words.

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

Example: the the quick brown fox

Text

Quoted String

Matches strings wrapped in single or double quotes.

/"[^"]*"|'[^']*'/g

Example: "hello world" or 'foo bar'

Text

Emoji

Matches common emoji characters.

/[\u{1F300}-\u{1F9FF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/gu Invalid

Example: 🎉 Hello! 🚀

Text

Hashtag

Matches social media hashtags.

/#[a-zA-Z]\w*/g

Example: #webdev #javascript

Text

@Mention

Matches @username mentions.

/@[a-zA-Z0-9_]{1,50}/g

Example: @john_doe or @user123

Identifiers

UUID v4

Matches a UUID version 4 string.

/[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/gi

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

Identifiers

GUID (general)

Matches any GUID/UUID format regardless of version.

/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/g

Example: A8098C1A-F86E-11DA-BD1A-00112444BE1E

Identifiers

US Social Security Number

Matches a US SSN in XXX-XX-XXXX format, excluding invalid prefixes.

/\b(?!000|666|9\d{2})\d{3}-(?!00)\d{2}-(?!0000)\d{4}\b/g

Example: 123-45-6789

Identifiers

Credit Card Number

Matches Visa, Mastercard, Amex, and Discover card numbers.

/\b(?: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})\b/g

Example: 4111111111111111

Identifiers

UK Passport Number

Matches a UK passport number (9 digits).

/[0-9]{9}/g

Example: 123456789

Identifiers

ISBN-10

Matches an ISBN-10 book identifier.

/\b(?:\d[\s-]?){9}[\dX]\b/gi

Example: 0-306-40615-2

Identifiers

ISBN-13

Matches an ISBN-13 book identifier.

/\b97(?:8|9)[\s-]?(?:\d[\s-]?){9}\d\b/g

Example: 978-0-306-40615-7

Identifiers

CSS Named Colour

Matches common CSS named colours.

/\b(?:red|blue|green|yellow|orange|purple|pink|black|white|gray|grey|cyan|magenta|lime|indigo|violet|brown|teal|navy|maroon)\b/gi

Example: The sky is blue and the grass is green.

Identifiers

Valid Variable Name

Validates a JavaScript/Python style variable name.

/^[a-zA-Z_$][a-zA-Z0-9_$]*$/

Example: myVar, _count, $element

Identifiers

Semantic Version (SemVer)

Matches semantic version strings like 1.2.3 or 2.0.0-beta.1.

/\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?\b/g

Example: 1.0.0, 2.3.1-alpha.1, v3.0.0+build.123

Networking

IPv4 Address

Matches a valid IPv4 address.

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

Example: 192.168.1.1 or 255.255.255.0

Networking

IPv6 Address

Matches full and compressed IPv6 addresses.

/([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::(?:[0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}/gi

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

Networking

CIDR Notation

Matches an IPv4 address with CIDR subnet mask.

/\b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\/(?:[0-9]|[1-2]\d|3[0-2])\b/g

Example: 192.168.1.0/24

Networking

MAC Address

Matches MAC addresses with colon or hyphen separators.

/([0-9A-Fa-f]{2}[:\-]){5}[0-9A-Fa-f]{2}/g

Example: 00:1A:2B:3C:4D:5E

Networking

Port Number

Matches a valid TCP/UDP port number (0–65535) preceded by colon.

/:(6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)/g

Example: :8080 or :443

Networking

Localhost URL

Matches localhost URLs with optional port and path.

/https?:\/\/localhost(?::\d{1,5})?(?:\/[^\s]*)?/gi

Example: http://localhost:3000/api/users

Networking

JSON Web Token (JWT)

Matches JWT tokens (header.payload.signature).

/ey[A-Za-z0-9_-]+\.ey[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+/g

Example: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjMifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c

Networking

Generic API Key

Loosely matches API keys (32–64 alphanumeric chars).

/\b[A-Za-z0-9_\-]{32,64}\b/g

Example: sk_live_abcdefghijklmnopqrstuvwxyz123456

HTML & Code

JS Single-line Comment

Matches single-line JavaScript/C-style comments.

/\/\/.*/g

Example: // This is a comment

HTML & Code

JS Multi-line Comment

Matches multi-line block comments /* ... */.

/\/\*[\s\S]*?\*\//g

Example: /* This is a multi-line comment */

HTML & Code

console.log() Call

Matches console.log, console.warn, console.error, etc. calls.

/console\.(?:log|warn|error|info|debug)\s*\([^)]*\)/g

Example: console.log("hello") or console.error(err)

HTML & Code

ES6 Import Statement

Matches ES6 import statements.

/import\s+(?:[\w{},\s*]+\s+from\s+)?['"][^'"]+['"]/g

Example: import { useState } from 'react'

HTML & Code

CommonJS require()

Matches Node.js require() statements.

/require\s*\(['"][^'"]+['"]\)/g

Example: const fs = require('fs')

Email & Web

Email Username (local part)

Extracts the username (local part) from an email address.

/^[a-zA-Z0-9._%+\-]+(?=@)/

Example: user.name+tag@example.com → user.name+tag

Email & Web

Email Domain Part

Extracts the domain part from an email address (lookbehind).

/(?<=@)[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}/g

Example: user@example.com → example.com

Email & Web

URL Path Segment

Matches individual path segments in a URL.

/(?<=\/)[a-zA-Z0-9\-._~!$&'()*+,;=:@%]+/g

Example: https://example.com/api/v2/users → api, v2, users

Phone

Australian Phone Number

Matches Australian phone numbers including +61 prefix.

/(?:\+61|0)(?:\s?[2-9]\d){4}(?:\s?\d{4})/g

Example: +61 2 1234 5678 or 02 1234 5678

Phone

Phone with Extension

Matches phone numbers with optional extensions.

/\(?\d{3}\)?[\s.\-]?\d{3}[\s.\-]?\d{4}(?:\s*(?:ext|x|#)\s*\d{1,6})?/gi

Example: (555) 123-4567 ext 890

Dates & Time

Month Name

Matches full or abbreviated month names.

/\b(?:January|February|March|April|May|June|July|August|September|October|November|December|Jan|Feb|Mar|Apr|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\b/gi

Example: March 15, 2024 or Mar 15

Dates & Time

Day of Week

Matches full or abbreviated day names.

/\b(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday|Mon|Tue|Wed|Thu|Fri|Sat|Sun)\b/gi

Example: Monday or Mon

Dates & Time

Duration (HH:MM:SS)

Matches time duration in HH:MM:SS format.

/\b\d{1,2}:\d{2}:\d{2}\b/g

Example: 01:30:00 (1.5 hours)

Numbers

US ZIP Code

Matches US ZIP codes (5 digits or ZIP+4 format).

/\b\d{5}(?:-\d{4})?\b/g

Example: 90210 or 90210-1234

Numbers

UK Postcode

Matches UK postcodes in standard formats.

/[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}/i

Example: SW1A 1AA or M1 1AE

Numbers

Roman Numeral

Matches Roman numerals (I to MMMM).

/\b(?:M{0,4}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3}))\b/gi

Example: Chapter IV or XLII

Passwords

Contains Uppercase Letter

Lookahead to check if a string contains at least one uppercase letter.

/(?=.*[A-Z])/

Example: Password123 ✓, password123 ✗

Passwords

Contains Special Character

Lookahead to check for at least one special character.

/(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>/?])/

Example: Pass!word ✓, Password ✗

Files & Paths

Code File Extension

Matches common source code file extensions.

/\.(js|ts|jsx|tsx|py|rb|php|java|cs|cpp|c|go|rs|swift|kt|vue|svelte|html|css|scss|sass|less)$/i

Example: component.tsx, styles.scss

Files & Paths

Hidden File (Unix)

Matches Unix hidden files (starting with a dot).

/(?:^|\/)\.(?!\.)([^\/]+)/g

Example: .gitignore, .env, .htaccess

Files & Paths

.env Variable

Matches environment variable declarations in .env files.

/^([A-Z_][A-Z0-9_]*)=(.*)$/gm

Example: DATABASE_URL=postgres://localhost/mydb

Text

Phone Number in Text

Loosely finds phone numbers mentioned in text with context.

/\b(?:call|phone|tel|fax|mobile|mob)?\s*:?\s*[+]?[\d\s()\-.]{7,20}/gi

Example: Call us: 555-123-4567

Text

camelCase Word

Matches camelCase identifiers.

/\b[a-z][a-zA-Z0-9]*[A-Z][a-zA-Z0-9]*\b/g

Example: myVariable, getUserData

Text

PascalCase Word

Matches PascalCase/UpperCamelCase words.

/\b[A-Z][a-z]+(?:[A-Z][a-z]+)+\b/g

Example: MyComponent, UserProfile

Text

snake_case Word

Matches snake_case identifiers.

/\b[a-z][a-z0-9]*(?:_[a-z0-9]+)+\b/g

Example: my_variable, user_profile_id

Text

kebab-case Word

Matches kebab-case identifiers used in CSS and URLs.

/\b[a-z][a-z0-9]*(?:-[a-z0-9]+)+\b/g

Example: my-component, user-profile-id

Identifiers

IBAN (International Bank Account)

Matches IBAN bank account numbers.

/[A-Z]{2}\d{2}[A-Z0-9]{4}\d{7}(?:[A-Z0-9]?){0,16}/g

Example: GB29NWBK60161331926819

Identifiers

SWIFT / BIC Code

Matches SWIFT/BIC bank identification codes.

/\b[A-Z]{4}[A-Z]{2}[A-Z0-9]{2}(?:[A-Z0-9]{3})?\b/g

Example: NWBKGB2L or DEUTDEDB

Identifiers

Stock Ticker Symbol

Matches stock ticker symbols prefixed with $.

/\$[A-Z]{1,5}\b/g

Example: $AAPL, $TSLA, $MSFT

Networking

SSH Public Key

Matches SSH public keys.

/(?:ssh-rsa|ssh-ed25519|ecdsa-sha2-nistp256)\s+[A-Za-z0-9+/]+={0,2}(?:\s+\S+)?/g

Example: ssh-rsa AAAAB3NzaC1yc2E... user@host

Networking

Git Commit SHA

Matches full (40-char) or abbreviated (7–8 char) Git commit SHAs.

/\b[0-9a-f]{40}\b|\b[0-9a-f]{7,8}\b/g

Example: a3f1b2c or a3f1b2cdef1234567890abcdef12345678901234

Networking

Docker Image Tag

Matches Docker image references with optional tag.

/[a-z0-9]+(?:[._\-][a-z0-9]+)*(?:\/[a-z0-9]+(?:[._\-][a-z0-9]+)*)*(?::[a-zA-Z0-9._\-]+)?/g

Example: nginx:latest or myrepo/myimage:1.2.3

About Regex Pattern Library

The Regex Pattern Library is a curated collection of over 100 production-ready regular expressions covering the most common developer tasks — from email and URL validation to log parsing, date extraction, and security filtering. Every pattern ships with a plain-English description, usage examples, and a live tester so you can verify matches against your own text before copying.

  • 100+ patterns organised across categories: Email, URL, Date, IP, Password, HTML, and more
  • Live in-browser tester with match highlighting and global/case-insensitive/multiline flags
  • One-click copy — grab the exact regex string ready to paste into any language
  • Full-text search by name, description, tag, or pattern fragment
  • All processing runs client-side — your test strings are never sent to a server

How to Use the Regex Library

  1. 1

    Search or browse by category

    Type a keyword (e.g. "email", "phone", "date") into the search bar, or click a category pill to filter patterns. Results update instantly.

  2. 2

    Read the description and example

    Each card shows what the pattern matches and a sample string so you can quickly decide if it fits your use case.

  3. 3

    Open the live tester

    Click the play button (▶) on any card to expand the live tester. Paste your own text and see matches highlighted in real time.

  4. 4

    Adjust flags if needed

    Toggle g (global), i (case-insensitive), or m (multiline) to change matching behaviour for your specific input.

  5. 5

    Copy and use

    Click Copy to copy the pattern string to your clipboard, then paste it into JavaScript, Python, Go, or any other language.

Tip: Click any tag pill (shown below a pattern) to instantly filter the library to all patterns sharing that tag — great for discovering related patterns.

Common Use Cases

Form Validation

  • • Validate email address format before submission
  • • Enforce password complexity rules (uppercase, digits, symbols)
  • • Verify phone number and ZIP code formats

Data Extraction

  • • Pull dates, times, and ISO timestamps from raw text
  • • Extract IP addresses and domain names from server logs
  • • Parse structured fields from CSV or fixed-width files

Input Sanitisation

  • • Strip or escape HTML tags from user-supplied content
  • • Remove script injection patterns before rendering
  • • Normalise whitespace and control characters in imports

Log Analysis

  • • Match error patterns in application or server logs
  • • Filter HTTP status codes from access logs
  • • Identify slow queries or stack traces in output

Search & Replace

  • • Bulk-rename variables or symbols in an editor
  • • Find and replace with capture groups across files
  • • Transform data formats (e.g. date MM/DD/YYYY → YYYY-MM-DD)

API & URL Routing

  • • Define route patterns in Express, FastAPI, or similar frameworks
  • • Validate URL slugs, UUIDs, and API key formats
  • • Parse query string parameters from raw request strings

Frequently Asked Questions

What is a regular expression (regex)?

A regular expression is a sequence of characters that defines a search pattern. It's used in programming to find, match, extract, or replace text based on rules — for example, matching every string that looks like an email address or an IP address.

Are these patterns compatible with JavaScript, Python, and other languages?

Most patterns are compatible with all major languages (JavaScript, Python, Java, Go, PHP, Ruby). The live tester runs JavaScript's built-in RegExp, so results may vary slightly for language-specific syntax extensions like Python's (?P<name>) named groups. The pattern string itself is always copied without language-specific delimiters.

Is my text safe when I use the live tester?

Yes. All matching runs entirely in your browser using JavaScript. The text you paste is never sent to any server, logged, or stored anywhere.

What do the g, i, and m flags do?

g (global) finds all matches instead of stopping at the first. i (case-insensitive) makes the pattern ignore uppercase/lowercase differences. m (multiline) makes ^ and $ match the start and end of each line instead of the whole string.

Can I modify a pattern before using it?

Yes — click Copy to get the pattern, then edit it in your code editor or test environment. The library patterns are starting points; adjust character classes, anchors, or quantifiers to fit your exact requirements.

Are these patterns safe to use in production without modification?

They are well-tested and widely used, but regex alone is rarely sufficient for security-critical validation. Always combine regex with additional server-side checks, especially for passwords, URLs, and financial data. Use the live tester to confirm the pattern handles your edge cases before deploying.

How do I search for a specific pattern I need?

Use the search bar at the top to type any keyword — e.g. "credit card", "hex color", "IPv6". You can also click a category tab to browse all patterns in that group, or click a tag pill on any card to see related patterns.

Can I suggest a new pattern to add to the library?

The library is regularly expanded. If you need a pattern that isn't here, you can use the search to find something close and adapt it, or combine multiple simpler patterns in your code for complex matching scenarios.