Your data is never sent to a server or stored anywhere. All processing happens in your browser.

Regex Tester

Common patterns Click to load the pattern and a sample input
Flags
Matches 0 matches found
No matches found
Pattern Explanation
Enter a pattern to see its explanation
Quick Reference
Code Snippets
Enter a pattern to generate code

How to Use


Enter a regex pattern and flags (g for global, i for case-insensitive, m for multiline, s for dotAll, u for unicode). Type test text below to see matches highlighted in real time, including capture groups and match positions. Switch to the Replace tab for substitution, or scroll down for pattern explanation, code snippets, and a quick reference.

Regular Expression Flags


g (global) finds all matches, not just the first. i (case-insensitive) ignores letter case. m (multiline) makes ^ and $ match line boundaries. s (dotAll) makes . match newlines. u (unicode) enables full Unicode matching. d (hasIndices) provides start/end indices for capture groups.

Common Use Cases


  • Form validation — email addresses, phone numbers, postal codes, and other input checks
  • Log parsing — extracting error messages, IP addresses, and timestamps
  • Text replacement — normalizing whitespace, unifying half/full-width characters, batch formatting
  • Scraping — pulling patterns out of HTML (use a real parser for complex structures, regex only for simple cases)
  • Find and refactor — flexible pattern matching across editor project-wide search

Common Pitfalls


  • Catastrophic backtracking — nested quantifiers like `(a+)+` can take exponential time on certain inputs, causing ReDoS (regex denial of service)
  • Greedy vs lazy matching — `.*` is greedy (as long as possible) by default; `.*?` is lazy. Critical when extracting HTML tags
  • Locale and Unicode — `\w` matches only ASCII letters/digits/underscore, not Japanese or emoji. Use the `u` flag and `\p{...}` properties for Unicode
  • Dialect differences — JavaScript, Python, PCRE, and Java differ on features and syntax (lookbehind support, recursion, conditionals)
  • Anchor misuse — without the `m` flag, `^` and `$` match only the start/end of the whole string, not each line

Privacy


All regex evaluation happens entirely in your browser using JavaScript's built-in RegExp engine. No patterns or test strings are sent to a server, stored, or logged.