Regex Pattern Library
Browse and copy common regex patterns for emails, URLs, dates, IPs, and more.
Pattern Library
Email Address
Matches standard email addresses
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$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()@:%_+.~#?&\/=]*)US Phone Number
Matches US phone numbers in various formats
(?:\+1[-\s.]?)?\(?\d{3}\)?[-\s.]?\d{3}[-\s.]?\d{4}IPv4 Address
Matches valid IPv4 addresses (0.0.0.0 - 255.255.255.255)
(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)IPv6 Address
Matches full IPv6 addresses
(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}Date (YYYY-MM-DD)
Matches dates in ISO format
\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])Date (MM/DD/YYYY)
Matches dates in US format
(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12]\d|3[01])\/\d{4}Time (HH:MM:SS)
Matches 24-hour time format
(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\dHex Color Code
Matches 3 or 6 digit hex color codes
#(?:[0-9a-fA-F]{3}){1,2}HTML Tag
Matches opening and closing HTML tags
<([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>(?:.*?)<\/\1>Credit Card Number
Matches Visa, MasterCard, Discover, and Amex formats
(?:4\d{3}|5[1-5]\d{2}|6011|3[47]\d{2})[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}US ZIP Code
Matches 5-digit and ZIP+4 formats
\d{5}(?:-\d{4})?Username
3-16 chars: letters, numbers, underscore, hyphen
^[a-zA-Z0-9_-]{3,16}$Strong Password
Min 8 chars with upper, lower, digit, and special char
^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$File Extension
Matches file extensions
\.([a-zA-Z0-9]{1,10})$CSS Property
Matches CSS property declarations
[a-z-]+\s*:\s*[^;]+;Whitespace Trimming
Matches leading and trailing whitespace
^\s+|\s+$Duplicate Words
Finds consecutive duplicate words
\b(\w+)\s+\1\bNumber with Commas
Matches formatted numbers like 1,234,567.89
\d{1,3}(?:,\d{3})*(?:\.\d+)?Slug (URL-friendly)
Matches URL-friendly slugs
^[a-z0-9]+(?:-[a-z0-9]+)*$Select a pattern or enter your own regex
Browse the pattern library below to get started
Related Tools
Regex TesterNEW
Test and debug regular expressions with real-time matching, highlighting, and explanation.
JSON Formatter
Format, beautify, minify, and validate JSON data online with instant error detection.
Diff CheckerNEW
Compare two texts and see the differences highlighted. Side-by-side or inline view.
Hash GenNEW
Generate MD5, SHA-1, SHA-256, and SHA-512 hashes from text instantly.
Frequently Asked Questions
What is a regex generator?
What common regex patterns are included?
Can I test regex patterns against my own text?
What regex flags are supported?
How do I copy a regex pattern?
Is this tool suitable for production regex?
How to Use the Regex Generator
Regular expressions are one of the most powerful tools in a developer's toolkit, but writing them from scratch can be time-consuming and error-prone. Our Regex Generator provides a curated library of tested patterns for the most common validation and matching tasks, along with a real-time tester to verify your patterns against sample data.
Step 1: Browse the pattern library. Explore our collection of common regex patterns organized by category. Each pattern comes with a description explaining what it matches and common use cases. Click any pattern to load it into the tester.
Step 2: Test against your data. Paste sample text into the test area and see real-time match highlighting. The tool shows all matches in your text, helping you verify that the pattern works correctly for your specific data format and edge cases.
Step 3: Copy and use. Once you are satisfied with the pattern, click the copy button to copy it to your clipboard. Use it directly in your JavaScript, Python, PHP, or any language that supports regular expressions.
Understanding Regular Expressions
Regular expressions (regex) are sequences of characters that define search patterns. They are used in virtually every programming language for string matching, validation, search and replace operations, and data extraction. While the syntax can seem cryptic at first, regex follows logical rules that become intuitive with practice.
The basic building blocks of regex include literal characters, character classes (like \d for digits and \w for word characters), quantifiers (like + for one or more and * for zero or more), anchors (^ for start and $ for end of string), and groups (parentheses for capturing matched text). Combining these elements lets you describe complex text patterns concisely.
JavaScript, the language running in your browser, uses the RegExp object for regex operations. The test() method checks if a pattern matches a string, the match() method returns match details, and String methods like replace() and split() accept regex patterns. Understanding these methods is essential for effective text processing in web development.
Common Regex Pattern Use Cases
Form validation. The most common use of regex in web development is validating user input in forms. Email addresses, phone numbers, postal codes, and passwords all have specific format requirements that regex can enforce. Client-side validation provides instant feedback to users before form submission.
Data extraction. When processing text data, regex helps you extract specific information like dates, amounts, identifiers, or structured data from unstructured text. This is essential for log parsing, data cleaning, web scraping, and ETL processes.
Search and replace. Text editors and IDEs use regex for powerful search and replace operations. You can find all occurrences of a pattern and replace them with transformed text, including captured groups from the original match. This is invaluable for code refactoring and bulk text transformations.
URL routing. Web frameworks use regex patterns to define URL routes and extract parameters. Express.js, Django, Ruby on Rails, and many other frameworks rely on regex-based routing to map incoming requests to the correct handler functions.