Regular Expressions Database

A comprehensive collection of the most popular regular expressions organized by category. Copy and use these tested patterns in your projects.

Email Basic
Email Validation
Basic email validation pattern that matches most common email formats
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Email Strict
Email Validation
RFC 5322 compliant email validation with more strict requirements
^[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])?)*$
Email Simple
Email Validation
Simple email pattern for finding emails in text
\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b
Phone Us
Phone Numbers
US phone number format including variations with country code, parentheses, and separators
^(\+1\s?)?\(?([0-9]{3})\)?[\s.-]?([0-9]{3})[\s.-]?([0-9]{4})$
Phone International
Phone Numbers
International phone number format starting with + and 7-15 digits
^\+(?:[0-9] ?){6,14}[0-9]$
Phone Basic
Phone Numbers
Basic phone number pattern accepting 10-15 digits with optional + prefix
^[\+]?[0-9]{10,15}$
Url Http
URLs & Web
HTTP/HTTPS URL validation including www subdomain and query parameters
^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&=]*)$
Url Domain
URLs & Web
Domain name validation without protocol
^[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}$
Url Ip
URLs & Web
IPv4 address validation pattern
^(?:(?: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]?)$
Url Slug
URLs & Web
URL slug pattern with lowercase letters, numbers, and hyphens
^[a-z0-9]+(?:-[a-z0-9]+)*$
Url Youtube
URLs & Web
YouTube URL validation for both youtube.com and youtu.be formats
^(https?\:\/\/)?(www\.)?(youtube\.com|youtu\.be)\/.+$
Password Strong
Password Validation
Strong password requiring lowercase, uppercase, digit, special character, minimum 8 characters
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Password Medium
Password Validation
Medium strength password with letters and numbers, minimum 6 characters
^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d@$!%*?&]{6,}$
Password No Spaces
Password Validation
Password pattern that doesn't allow spaces, minimum 4 characters
^[^\s]{4,}$
Number Integer
Numbers & Math
Integer number including negative values
^-?\d+$
Number Decimal
Numbers & Math
Decimal number with optional negative sign and decimal places
^-?\d+(\.\d+)?$
Number Positive
Numbers & Math
Positive integer greater than zero
^\d*[1-9]\d*$
Number Currency
Numbers & Math
Currency format with optional dollar sign, commas, and two decimal places
^\$?[0-9]{1,3}(?:,[0-9]{3})*(?:\.[0-9]{2})?$
Number Percentage
Numbers & Math
Percentage format from 0% to 100% with up to two decimal places
^\d{1,3}(\.\d{1,2})?%$
Number Zip Us
Numbers & Math
US ZIP code format (5 digits or ZIP+4)
^\d{5}(-\d{4})?$
Text Credit Card
Numbers & Math
Credit card number validation for major card types
^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3[0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})$
Date Mmddyyyy
Date & Time
MM/DD/YYYY date format with validation for months and days
^(0[1-9]|1[0-2])\/(0[1-9]|[12][0-9]|3[01])\/(19|20)\d{2}$
Date Ddmmyyyy
Date & Time
DD/MM/YYYY date format with validation for days and months
^(0[1-9]|[12][0-9]|3[01])\/(0[1-9]|1[0-2])\/(19|20)\d{2}$
Date Iso
Date & Time
ISO 8601 date format YYYY-MM-DD
^\d{4}-\d{2}-\d{2}$
Time 24h
Date & Time
24-hour time format HH:MM
^([01]?[0-9]|2[0-3]):[0-5][0-9]$
Time 12h
Date & Time
12-hour time format with AM/PM indicator
^(0?[1-9]|1[0-2]):[0-5][0-9]\s?(AM|PM|am|pm)$
Text Alphanumeric
Text Processing
Alphanumeric characters only (letters and numbers)
^[a-zA-Z0-9]+$
Text Username
Text Processing
Username format: 3-16 characters, letters, numbers, and underscores
^[a-zA-Z0-9_]{3,16}$
Text No Special
Text Processing
Text without special characters (letters, numbers, spaces only)
^[a-zA-Z0-9\s]+$
Text Sentence
Text Processing
Sentence format starting with capital letter and ending with punctuation
^[A-Z][a-zA-Z0-9\s.,!?';:-]*[.!?]$
Text Words
Text Processing
Extract individual words from text
\b\w+\b
Text Uuid
Text Processing
UUID (Universally Unique Identifier) format validation
^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$
Text Base64
Text Processing
Base64 encoded string validation
^[A-Za-z0-9+\/]*={0,2}$
Text Mac Address
Text Processing
MAC address validation with colon or hyphen separators
^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$
Text Ssn
Text Processing
US Social Security Number format (XXX-XX-XXXX)
^\d{3}-\d{2}-\d{4}$
Text Isbn
Text Processing
ISBN (International Standard Book Number) validation for both ISBN-10 and ISBN-13
^(?:ISBN(?:-1[03])?:? )?(?=[0-9X]{10}$|(?=(?:[0-9]+[- ]){3})[- 0-9X]{13}$|97[89][0-9]{10}$|(?=(?:[0-9]+[- ]){4})[- 0-9]{17}$)(?:97[89][- ]?)?[0-9]{1,5}[- ]?[0-9]+[- ]?[0-9]+[- ]?[0-9X]$
Html Tag
HTML & XML
HTML tags including opening and closing tags with attributes
<\/?[a-zA-Z][a-zA-Z0-9]*\b[^>]*>
Html Remove Tags
HTML & XML
Remove all HTML tags from text
<[^>]*>
Html Comments
HTML & XML
HTML comments including multiline comments
<!--[\s\S]*?-->
Html Hex Color
HTML & XML
Hexadecimal color codes (3 or 6 digits)
#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})\b
File Extension
File Paths & Names
File extension from filename
\.([a-zA-Z0-9]+)$
File Image
File Paths & Names
Image file extensions
\.(jpg|jpeg|png|gif|bmp|svg|webp)$
File Path Unix
File Paths & Names
Unix/Linux file path validation
^\/(?:[^\/\0]+\/)*[^\/\0]*$
File Path Windows
File Paths & Names
Windows file path validation
^[a-zA-Z]:\\(?:[^\\/:*?"<>|\0]+\\)*[^\\/:*?"<>|\0]*$
Social Twitter
Social Media
Twitter handle format with @ symbol
^@[A-Za-z0-9_]{1,15}$
Social Instagram
Social Media
Instagram handle format
^@[A-Za-z0-9_.]{1,30}$
Social Hashtag
Social Media
Social media hashtag format
#[A-Za-z0-9_]+

How to Use Regular Expressions

Learn about regex patterns, their syntax, and how to implement them in your code.

Regular Expressions Database - Complete Guide

What are Regular Expressions?

Regular expressions (regex) are powerful pattern-matching tools used in programming and text processing. They provide a concise and flexible way to search, match, and manipulate text based on specific patterns.

How to Use This Database

Our regex database contains 50+ carefully curated regular expressions organized into categories:

Categories Available

  • Email Validation: Patterns for validating email addresses
  • Phone Numbers: International and regional phone number formats
  • URLs & Web: Web addresses, domains, and internet-related patterns
  • Password Validation: Security requirements for strong passwords
  • Numbers & Math: Numeric patterns and mathematical expressions
  • Date & Time: Date and time format validation
  • Text Processing: Common text manipulation patterns
  • HTML & XML: Markup language processing
  • File Paths & Names: File system validation
  • Social Media: Platform-specific patterns

Common Use Cases

1. Form Validation

Use these patterns to validate user input in forms:

  • Email addresses
  • Phone numbers
  • Passwords
  • URLs

2. Data Processing

Extract and validate data from text:

  • Parse log files
  • Extract phone numbers from documents
  • Validate file formats

3. Content Filtering

Filter and search content:

  • Find specific patterns in text
  • Remove unwanted characters
  • Format data consistently

Implementation Tips

JavaScript Example

const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
const isValidEmail = emailPattern.test("user@example.com");

Python Example

import re
pattern = r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$'
is_valid = re.match(pattern, "user@example.com") is not None

PHP Example

$pattern = '/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/';
$isValid = preg_match($pattern, "user@example.com");

Best Practices

  1. Test Thoroughly: Always test regex patterns with various inputs
  2. Performance: Be mindful of performance with complex patterns
  3. Readability: Use comments to explain complex patterns
  4. Escaping: Properly escape special characters
  5. Validation: Combine regex with additional validation logic

Security Considerations

  • Input Sanitization: Always sanitize input before processing
  • ReDoS Prevention: Avoid patterns that can cause exponential backtracking
  • Length Limits: Implement reasonable length limits for input
  • Server-side Validation: Never rely solely on client-side validation