Regex Pattern Library
52+ searchable common regex patterns. Browse by category, search by name, or click any pattern to test it against your own input.
How to Use the Regex Pattern Library
- Search mode — type keywords like "email", "phone", or "date" to filter the pattern list in real time.
- By Category — click a category chip to browse all patterns in that group (Validation, Strings, Numbers, Dates, Web, Code).
- Test Mode — click any pattern card to open the test panel. Enter test strings (one per line) to see which match.
- Copy — click the copy button on any card or in the test panel to copy the raw regex to your clipboard.
Understanding Regular Expressions
A regular expression is a sequence of characters forming a search pattern. The pattern is applied to a string to find matches. Regex is supported natively in JavaScript, Python, Java, Go, Ruby, PHP, Perl, Rust, and virtually every other programming language. The syntax is largely standardised across languages, though there are minor differences in advanced features like lookbehind assertions and named groups.
Core Regex Syntax
.— matches any single character except newline*— zero or more of the preceding element+— one or more of the preceding element?— zero or one of the preceding element (also makes quantifiers lazy){n,m}— between n and m repetitions^— start of string (or line in multiline mode)$— end of string (or line in multiline mode)[abc]— character class: a, b, or c[^abc]— negated class: anything except a, b, or c\d— digit (0-9);\w— word character;\s— whitespace(abc)— capturing group;(?:abc)— non-capturing groupa|b— alternation: a or b(?=...)— lookahead;(?<=...)— lookbehind
Practical Uses of Regex
Form validation is the most common frontend use: ensuring an email address looks plausible, a phone number has the right format, or a password meets complexity requirements. Backend use is even broader: parsing log files to extract timestamps and error codes, validating API inputs before hitting a database, extracting structured data from unstructured text (receipts, documents, web scrapes), and finding and replacing strings in code editors. Many code editors (VS Code, Vim, Emacs) support regex-based find-and-replace, which is powerful for large-scale refactors. For live regex testing with highlighting and match groups, use our dedicated Regex Tester tool.
When Not to Use Regex
Regex is powerful but not always the right tool. Never use regex to parse HTML — use a proper DOM parser or library like Cheerio. Email validation with regex should be a pre-filter only — always confirm ownership via a verification email. Parsing nested structures (JSON, XML, code) with regex is fragile; use a proper parser. Complex URL parsing should use the browser's built-in URL constructor. For date parsing, use a dedicated date library rather than constructing a regex that handles all possible date formats and timezone offsets. Catastrophic backtracking is a real denial-of-service vulnerability: always test regex patterns with adversarial inputs, and prefer {n,m} quantifiers over .* when possible.