Regex Tester: Test Regular Expressions in Real Time
Type a pattern, paste some text and see every match highlighted as you type, with its position and capture groups. Try a replacement and read what each part of the pattern does
Pattern and Text
Uses your browser’s regular expression engine, so the syntax is JavaScript’s. Nothing you type leaves your browser.
Index counts characters from 0. Matches are found in order and never overlap. Empty matches are listed but not highlighted.
Matches
| # | Index | Match | Groups |
|---|---|---|---|
| 1 | 8 | 2026-10-12 | 1: 2026 2: 10 3: 12 |
| 2 | 28 | 2026-11-03 | 1: 2026 2: 11 3: 03 |
| 3 | 53 | 2027-01-15 | 1: 2027 2: 01 3: 15 |
What the pattern does
(Group 1 starts and captures what it matches\dA digit (0 to 9){4}Repeat the previous part: exactly 4 times)The group ends-The text “-”(Group 2 starts and captures what it matches\dA digit (0 to 9){2}Repeat the previous part: exactly 2 times)The group ends-The text “-”(Group 3 starts and captures what it matches\dA digit (0 to 9){2}Repeat the previous part: exactly 2 times)The group endsHow to use this tool
- Type your pattern and tick the flags you need, or pick an example. Paste the text to test below it.
- Read the highlighted matches, the list with positions and groups, and the explanation of each part of the pattern.
- Turn on the replacement option to preview the text after replacing the matches, then press Copy Result.
Worked example
Pattern (\d{4})-(\d{2})-(\d{2}) with the g flag finds every date written like 2026-10-12 and captures the year, the month and the day in groups 1, 2 and 3. Replacing it with $3/$2/$1 turns 2026-10-12 into 12/10/2026. Without the g flag, only the first date would be found and replaced.
Methodology
The tool builds a regular expression from your pattern and the flags you tick, using the engine built into your browser, so it follows JavaScript syntax. It runs the test in a background process: it finds each match in turn, records its position and capture groups, highlights it in your text and, if you ask for it, applies your replacement text. If a pattern takes more than about two seconds, the test is stopped so the page keeps working. The explanation below the results is produced by a simple reader of your pattern text. It describes the common building blocks one by one. Everything runs in your browser and nothing is uploaded or stored.
Common patterns, explained
A few short patterns you can paste into the tester, with what each one does.
| Pattern | What it matches |
|---|---|
| \d{4}-\d{2}-\d{2} | A date shaped like 2026-10-12 (the shape only, not whether the date exists) |
| colou?r | The word color or color: the u is optional |
| \b(\w+)\s+\1\b | A word repeated right after itself, such as “the the” |
| ^\s+|\s+$ | Spaces at the start or end of the text (add the m flag for each line) |
| [^\s@]+@[^\s@]+\.[^\s@]+ | Something shaped like an email address (a quick shape, not a full validation) |
| (?<year>\d{4}) | Four digits captured in a group named year |
These are starting points. Test each one on your own text, because the right pattern depends on what your data really looks like.
Frequently asked questions
Which regex flavor does this tester use? ▼
It uses the regular expression engine built into your browser, which follows JavaScript syntax. Patterns written for PCRE, Python, Java or .NET often work, but features specific to those dialects, such as possessive quantifiers, atomic groups, \A, \Z or recursion, are not available.
What do the flags g, i, m, s, u and y do? ▼
g finds all matches instead of only the first. i ignores uppercase and lowercase. m makes ^ and $ match at the start and end of each line. s lets the dot match line breaks. u turns on Unicode mode. y makes the match start exactly where the search continues.
Why does the test stop with a timeout message? ▼
Some patterns, especially ones with nested repeats such as (a+)+, can make the engine try an enormous number of combinations. The tool runs the test in the background and stops it after about two seconds so the page keeps working. Simplify the pattern or make the repeats more specific.
How do I use captured groups in a replacement? ▼
Write $1, $2 and so on for numbered groups and $$ for a dollar sign. For example, replacing (\d{4})-(\d{2})-(\d{2}) with $3/$2/$1 turns 2026-10-12 into 12/10/2026.
Is my text sent anywhere? ▼
No. The pattern and the text are processed in your browser, so they stay on your device and nothing is saved. If you reload or close the page, the fields return to the default example.