What is regex testing?
Regular expressions (regex) are patterns that match character combinations in text. Write a pattern, choose its flags, and test it against your own text: every match is highlighted with its index and the value of each numbered and named capture group, and Replace mode previews the rewritten text. Matching runs in your browser with JavaScript's native RegExp engine.
How a regular expression works
A regular expression is a pattern that describes a set of strings. The engine reads your pattern left to right and tries to match it against the input text. Literal characters match themselves, while metacharacters like ., *, +, and ? describe repetition, position, and choice. When the pattern matches, the engine reports the matched text, its position, and the contents of any capture groups.
This tester uses the RegExp engine of the browser you are using, so results match what JavaScript and TypeScript code does in that engine. Syntax added in recent ECMAScript versions, such as the v flag or duplicate named groups, works only in engines that support it, so check your target browsers or Node.js version before relying on it. Results update as you type, and every capture group is listed so you can see precisely what each part of your pattern captured.
Regex flags
Flags change how the whole pattern is applied. The global flag (g) finds every match instead of stopping at the first. The ignore-case flag (i) makes matching case-insensitive. The multiline flag (m) makes ^ and $ match at line breaks. The dotAll flag (s) lets . match line breaks too. The unicode flag (u) matches by code point and enables \p{…} property escapes, and the unicodeSets flag (v) adds set operations inside character classes; use one or the other. The sticky flag (y) makes each match start exactly where the previous one ended, and the hasIndices flag (d) records where each match and group starts and ends. Combine flags as needed — for example gi to find all matches regardless of case.
Common regex mistakes
A few mistakes account for most broken patterns: forgetting to escape a literal dot or slash, relying on greedy quantifiers when a lazy one is needed, and omitting the global flag when you expect every match. Character classes are another trap — inside square brackets most metacharacters lose their special meaning, so [.] matches a literal dot, not any character.
When a pattern matches too much or too little, test it against several inputs — including edge cases and empty strings — and check the capture groups to see exactly what each part of the pattern consumed.
Nested quantifiers such as (a+)+ can backtrack catastrophically: on text that almost matches, the engine tries an exponential number of ways to split it. This tester runs each pattern in a background worker and stops it after 2 seconds, so the page stays responsive and you are told what happened.
How to test a regular expression
- 1Enter your pattern. Type your regex into the pattern field — you do not need the surrounding slashes.
- 2Set flags. Turn flags on with the buttons or type them after the closing slash: g (global), i (ignore case), m (multiline), s (dotAll), u or v (Unicode), y (sticky), and d (indices).
- 3Add test text. Paste the text you want to search. Results update as you type, with every match highlighted in the Results panel.
- 4Inspect matches and groups. Review each match, its index, and each numbered or named capture group; a group that took no part in the match is shown as not matched.
- 5Use Replace. Switch to Replace and enter a replacement: $1 or $<name> inserts a capture group, $& the whole match, and an empty replacement deletes every match. Copy output copies the rewritten text.
Examples
Match an email address
Tested against: contact ada@dev-toolbox.io
Input
[\w.+-]+@[\w-]+\.[\w.-]+
Output
ada@dev-toolbox.io
Capture date parts
Tested against: 2026-09-13
Input
(\d{4})-(\d{2})-(\d{2})Output
Group 1: 2026 · Group 2: 09 · Group 3: 13
Find all hashtags
Flag: g — tested against: #dev #tools #seo
Input
#\w+
Output
#dev, #tools, #seo
Match a US phone number
Tested against: (415) 555-0132
Input
\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}Output
(415) 555-0132
Regex quick reference
The most common tokens, as matched by JavaScript's RegExp engine.
| Token | Matches |
|---|---|
| \d | Any digit (0–9) |
| \w | Word character (a–z, A–Z, 0–9, _) |
| \s | Whitespace: space, tab, line breaks, and Unicode spaces |
| . | Any character except a line break (any character with s) |
| ^ / $ | Start / end of string (or line with m) |
| * | 0 or more of the preceding |
| + | 1 or more of the preceding |
| ? | 0 or 1 (optional) |
| {n,m} | Between n and m repetitions |
| [abc] | Any one of a, b, or c |
| [^abc] | Any character except a, b, or c |
| (...) | Capture group |
| a|b | a or b (alternation) |
| \b | Word boundary |
Frequently asked questions
Which regex flavor does this use?
The JavaScript (ECMAScript) RegExp engine of the browser you are using. Patterns behave the same in JavaScript, TypeScript, and Node.js wherever the engine supports their syntax; newer features such as the v flag and duplicate named groups need a recent engine. The syntax differs from PCRE, Python, and Java regex.
What are capture groups?
Parentheses ( ) create a capture group that remembers the part of the match inside them. Groups are numbered left to right by their opening parenthesis and can be referenced in replacements as $1, $2, and so on. A named group, (?<name>…), is numbered too and can also be referenced as $<name>.
What is the difference between greedy and lazy matching?
Quantifiers like * and + are greedy by default — they match as much as possible. Adding ? after them (*?, +?) makes them lazy, matching as little as possible. This matters when a pattern could match several lengths.
What do the regex flags do?
g finds all matches instead of the first; i ignores case; m makes ^ and $ match at line breaks; s (dotAll) lets . match line breaks; u matches by code point and allows \p{…} escapes; v (unicodeSets) extends u with set operations in character classes; y (sticky) makes each match start where the last one ended; d records the start and end of each match and group. They can be combined, such as gi, except u with v.
How do I match a literal special character?
Escape it with a backslash. For example \. matches a literal dot, \( matches a literal parenthesis, and \\ matches a literal backslash.
Is my test data private?
Yes. Matching runs in your browser, and your pattern and test text aren't sent to a server. The only exception is the Share link button: when you click it, it uploads the pattern, flags, test text, replacement, and result so the link can reopen them, so don't share text that contains personal data.
Is it free?
Yes — free to use, with no sign-up.
Can I use this to replace text with a pattern?
Yes. Switch to Replace mode and enter a replacement string. Use $1 or $<name> for a capture group, $& for the whole match, and $$ for a literal dollar sign, or leave it empty to delete every match. Without the g flag only the first match is replaced.
Why did matching stop after 2 seconds?
The pattern was most likely backtracking catastrophically. Nested quantifiers such as (a+)+ or (\w+\s?)* make the engine try an exponential number of ways to split text that almost matches. The tester runs each pattern in a background worker and stops it after 2 seconds so the page stays responsive. Make the pattern more specific, for example by removing the nested quantifier.