Regex Tester — Live Match, Replace & Explainer
. Any character except newline\d Any digit [0-9]\D Any non-digit [^0-9]\w Any word character [a-zA-Z0-9_]\W Any non-word character\s Any whitespace character\S Any non-whitespace character[abc] Match any character in the set[^abc] Match any character not in the set[a-z] Match a character in the range* Zero or more+ One or more? Zero or one (optional){n} Exactly n times{n,} n or more times{n,m} Between n and m times*? Zero or more (lazy)+? One or more (lazy)^ Start of string$ End of string\b Word boundary\B Non-word boundary(abc) Capturing group(?:abc) Non-capturing group(?<name>abc) Named capturing group\1 Backreference to group 1a|b Match a or b(?=abc) Positive lookahead(?!abc) Negative lookahead(?<=abc) Positive lookbehind(?<!abc) Negative lookbehindHow 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.
FAQ
Which regex engine does this tool use?
It uses your browser's built-in JavaScript RegExp engine. That means features like lookbehind and Unicode properties (\p{...}) follow the JavaScript spec, which differs in places from Python, PCRE, and Java. The generated code snippets target those languages, but the live matching reflects JavaScript behavior.
Are my patterns or test strings sent to a server?
No. Matching, replacing, and explanation all run in your browser's RegExp engine. You can paste production logs or test strings containing personal data — nothing is uploaded, stored, or logged.
How do the g, i, m, s, and u flags differ?
g (global) finds all matches, i ignores case, m makes ^ and $ match each line boundary, s lets . match newlines, and u enables full Unicode matching. You can combine multiple flags at once.
Why does the browser sometimes freeze?
Nested quantifiers like `(a+)+` can trigger catastrophic backtracking (ReDoS), taking exponential time on certain inputs. Since evaluation runs in your browser, such patterns can temporarily stall the tab.
Why doesn't `\w` match Japanese characters?
By specification `\w` matches only ASCII letters, digits, and underscore — it excludes Japanese characters and emoji. To match those, add the `u` flag and use Unicode property escapes such as `\p{L}` for any letter.