Regex Tester
Enter a pattern and see matches, capture groups and a piece-by-piece explanation as you type. Nothing you enter is sent to a server.
Loading the tool…
User reviews
No reviews yet. If you’ve used this tool, be the first to leave one.
Regex Tester: complete guide
Walk through the steps and examples, or jump straight to the topic you need.
At a glance
- Syntax
- Browser JavaScript regex.
- Flags
- You can turn six flags on and off: g, i, m, s, u and y.
- What it shows
- The matched spot, the start position, numbered groups and named groups.
- Replacing
- It uses the $1, $& and $<name> notation as is.
- Hang protection
- It runs in a separate worker and ends it if it passes 2 seconds.
- Size
- Text up to 200,000 characters, up to 5,000 matches, and the list shows the first 200.
- Safety
- Even if the test text contains tags, it is shown only as characters.
- Where it runs
- The pattern and the text are not sent to a server.
How to use Regex Tester
Enter a pattern
Write only the pattern between the slashes. You can also pick one from the common patterns and adapt it. If the pattern is invalid, the tool shows the reason the browser reports as is.
Try turning on flags
Turn on i to ignore case, or m to apply ^ and $ on every line. Hover over each button to see what it does.
Check the matches and groups
The matches are highlighted on the text. In the list below, you can see the position each match started at and the values captured in parentheses, one by one.
Preview the replacement too
Type the replacement text and the result appears right away. You can reuse groups like $1, so swapping the order of parts is checked too.
What it’s good for
It shows where and why a match happened
It highlights the matches right on top of your text, and below it lists each match with the position it started at and the values captured by each group in parentheses. Named groups are shown by their names, so when you use something like (?<year>\d{4}) you can immediately check that the value goes in properly. A group that did not match is written as "no match" rather than left blank.
It handles patterns that hang safely
A pattern that repeats the same thing in nested layers, like (a+)+, makes the computation explode and freezes the browser once the text gets even a little long. This tool runs the matching in a separate worker and ends that worker if it passes 2 seconds. The page does not freeze, and a message explains why it took so long and how to fix it.
Worked examples
Finding only dates
Pattern \d{4}-\d{2}-\d{2} · flag gThe two spots 2026-09-10 and 2026-10-01 are highlighted.Swapping parts
Pattern (?<y>\d{4})-(?<m>\d{2}) · replacement $<m>/$<y>2026-09 → 09/2026Flags that are often confused
Swipe the table sideways to see the rest.
| Flag | When on | When off |
|---|---|---|
| g (global) | Finds every match | Finds only the first match |
| i (ignore case) | Treats A and a as the same | Distinguishes them exactly |
| m (multiline) | ^ and $ match at every line | They match only at the start and end of the whole text |
| s (dot matches newline) | . also matches line breaks | . matches everything except line breaks |
When the result isn’t what you expected
It says the pattern took too long and was stopped
Repeating the same thing in nested layers, like (a+)+ or (.*)*, makes the number of possibilities explode as the text gets longer. Remove the inner repetition or narrow the range. It cuts off at 2 seconds so the page does not freeze.
It finds only one match
Global (g) is off. Turn it on to find them all.
I want to find a dot (.) or an asterisk (*) literally
Put a backslash in front of it. If you use the button that turns the first line of your text into a literal-match pattern, it is handled in one step.
The result differs in another language
This tool uses browser JavaScript syntax. Some notation differs from Python or Java, so check when you move a pattern.
Key terms
- Group
- The part wrapped in parentheses. You can pull out the matched value separately.
- Named group
- The form (?<name>...). You pull it out by name instead of by number.
- Flag
- A letter after the pattern, like g or i. It changes how matching works.
- Catastrophic backtracking
- A state where the number of possibilities explodes and the computation never finishes.
Regex Tester FAQ
Do I have to turn on Global (g)?
If you do not, it finds only the first match. In code, too, only the first match is used without g, so the tool deliberately shows it that way and notes the fact on screen.
Which language's regex is this?
It is browser JavaScript regex. Some notation differs from Python or Java. In particular, support for lookbehind and Unicode property notation can differ by environment.
Is my text uploaded to a server?
No. Both the pattern and the text are handled only inside this browser.
Can a pattern match an empty string?
Yes. A pattern like a*, which also matches empty spots, can loop forever because the position does not move, so the tool advances one character at a time and shows the match in the list as (empty string).
How many matches does it find?
It finds up to 5,000 and shows the first 200 in the list. The highlighting applies to everything found.
Can I put HTML in the test text?
Yes. It is drawn on screen only as characters, so tags are not executed.