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.

No pattern selected
52 patterns — Click any card to test it.

How to Use the Regex Pattern Library

  1. Search mode — type keywords like "email", "phone", or "date" to filter the pattern list in real time.
  2. By Category — click a category chip to browse all patterns in that group (Validation, Strings, Numbers, Dates, Web, Code).
  3. Test Mode — click any pattern card to open the test panel. Enter test strings (one per line) to see which match.
  4. 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 group
  • a|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.

Frequently Asked Questions

A regular expression is a sequence of characters that defines a search pattern. It is used for input validation, text extraction, string replacement, and splitting. Most programming languages support regex natively.
All patterns use JavaScript-compatible regex syntax, which is compatible with Python, Java, Go, PHP, and most modern languages with minor variations. Patterns are shown without surrounding slashes or flags.
RFC 5322 email rules are so complex that a fully correct regex is impractical. Use a simple regex to catch obvious errors, then send a verification email to confirm ownership in production.
Flags modify matching behavior: i (case-insensitive), g (global — find all matches), m (multiline — ^ and $ match line boundaries), s (dotAll — dot matches newlines). Add after the closing slash: /pattern/gi.
JavaScript: const regex = /pattern/g; const matches = text.match(regex); Python: import re; matches = re.findall(r'pattern', text). Copy the pattern from this library and use your language's regex API.