Regex Tester
Test regular expressions live with match highlighting, capture groups, and a quick syntax reference.
Matching runs entirely in your browser using JavaScript’s native regex engine — your pattern and test string are never sent anywhere.
Quick Syntax Reference
Bookmark this — it’s the cheatsheet most people come back to look up mid-project.
| Pattern | Matches |
|---|---|
. | Any character except a line break |
\d / \D | A digit / a non-digit |
\w / \W | A word character (letter, digit, underscore) / non-word character |
\s / \S | A whitespace character / non-whitespace character |
^ / $ | Start of string (or line, with the m flag) / end of string (or line) |
* / + / ? | 0 or more / 1 or more / 0 or 1 of the preceding item |
{n} / {n,} / {n,m} | Exactly n / n or more / between n and m occurrences |
[abc] / [^abc] | Any one of a, b, c / any character except a, b, c |
(...) / (?:...) | A capturing group / a non-capturing group |
| | Alternation — matches whatever is on either side |
\b | A word boundary |
What the Flags Above Actually Change
The g (global) flag tells the engine to keep searching after the first match, returning every occurrence instead of stopping at the first one — leave it checked unless you specifically want just the first match. i makes matching case-insensitive. m changes what ^ and $ mean: without it, they refer to the very start and end of the whole string; with it, they match the start and end of each line. s (dotall) makes the . pattern match newline characters too, which it otherwise skips. u enables full Unicode handling, needed for patterns using Unicode property escapes or working correctly with characters outside the basic Latin alphabet.
Common Mistakes That Waste the Most Debugging Time
Forgetting the g flag is the single most common issue — without it, a pattern that should find every match in a block of text silently returns only the first one, and code built around it will look “broken” for reasons that have nothing to do with the pattern itself. The second is forgetting to escape special characters that need a literal meaning: a period, parenthesis, or dollar sign inside a pattern needs a backslash in front of it (\., \(, \$) if you actually want to match that literal character rather than trigger its special regex meaning. The third, more advanced issue is catastrophic backtracking — certain nested-quantifier patterns (like (a+)+b against a long string with no trailing “b”) can cause the regex engine to try an exponential number of combinations before giving up, effectively freezing whatever’s running it. If a pattern seems to hang on longer inputs, that’s usually the cause.
How This Tool Helps You Debug Faster
Instead of writing throwaway console.log() statements to check whether a pattern matches, this tool highlights every match directly in your test string as you type, and breaks out each match’s exact position and any capture groups underneath — so you can immediately see not just whether it matched, but exactly what it matched and why a nearby piece of text didn’t. The quick-insert presets above (email, URL, phone, IP address, date, hex color) also double as a reference for how to structure similarly common patterns of your own.
Regex Tester — FAQ
Why does my pattern only find one match instead of all of them?
Check that the g (global) flag is turned on. Without it, JavaScript’s regex engine stops after the first match by default, which is one of the most common sources of “my regex isn’t working” confusion.
How do I match a literal period, parenthesis, or other special character?
Escape it with a backslash: \. matches a literal period, \( matches a literal opening parenthesis, and so on. Without the backslash, these characters trigger their special regex meaning instead of matching themselves.
What’s the difference between a capturing group and a non-capturing group?
(...) captures whatever it matches so you can reference it afterward (shown as “Group 1,” “Group 2,” etc. in the results above). (?:...) groups a pattern for structure — like applying a quantifier to multiple characters at once — without saving the matched text separately.
Why does my regex seem to freeze the page on long input?
This is usually catastrophic backtracking — certain patterns with nested repeating groups can cause the regex engine to try an enormous number of combinations on longer strings. If a pattern hangs, look for nested quantifiers like (a+)+ and try restructuring the pattern to avoid the ambiguity.
Is my pattern or test data sent anywhere?
No. Matching runs entirely in your browser using JavaScript’s built-in regex engine. Nothing you type into the pattern or test string fields is transmitted to or stored on a server.