04 / Testing / regex-tester
Regex Tester
Test regular expressions with groups, highlighting and replace.
How to use
- 01Type your regular expression in the pattern field, without the surrounding slashes. The slashes and active flags are shown around the field, so it reads like a JavaScript regex literal.
- 02Toggle the flags you need: i, m, s, u or y. Every match in the text is always found, so the g button does not change the results.
- 03Paste or type sample text into the Test string editor.
- 04Check the Highlighted panel to see each match marked in place, along with the total match count.
- 05Read Match details for each match's text, its starting index and its capture group values. If the pattern is invalid, the engine's error message appears under the pattern.
What is this tool?
A live JavaScript regular expression tester. As you type, matches are highlighted in your sample text, and each one is listed with its start index and capture groups. Patterns run on your browser's own ECMAScript engine, so the results match what new RegExp() and String.prototype.matchAll() return in JavaScript and Node.js. An invalid pattern shows the exact error the engine reports. Up to 500 matches are displayed, and nothing you type leaves your browser.
JavaScript regex flags explained
i makes matching case-insensitive. m (multiline) makes ^ and $ match at the start and end of every line instead of only the start and end of the whole string. In the text line1, newline, line2, the pattern ^line\d$ finds nothing without m and two matches with it. s (dotAll) lets . match newline characters too, so a.b matches a, newline, b only when s is on.
u turns on Unicode mode. It treats characters outside the Basic Multilingual Plane, such as emoji, as one character instead of two UTF-16 halves, and it enables \p{...} property escapes. y (sticky) only allows a match at the exact position where the previous one ended. Searching aaba for a finds two matches with y instead of three, because the b stops the chain.
The tester always runs in global mode so that it can list every match. That is why toggling g changes the flags shown next to the pattern but not the results. In your own code, remember that methods such as String.prototype.replace and match behave differently with and without g.
Common regex patterns for QA (email, UUID, dates)
The default pattern, \b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b with the i flag, is a practical email matcher. On the sample text it finds qa@example.com at index 8 and lead.dev@example.org at index 26, and it skips the incomplete not-an-email@. It is good for pulling addresses out of logs. It is not a full RFC 5322 validator.
For ISO dates, (\d{4})-(\d{2})-(\d{2}) matches 2026-01-01 and captures 2026, 01 and 01 as three groups, which Match details shows as groups: 2026 | 01 | 01. For UUIDs, use ^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$ with the i flag. It checks the version digit and the variant digit as well as the 8-4-4-4-12 layout. Add the m flag when you test one value per line, so that ^ and $ anchor to each line.
Greedy vs lazy matching and reading capture groups
Quantifiers such as * and + are greedy, which means they match as much as possible. Against <b>x</b><b>y</b>, the pattern <b>.*</b> returns one match covering the whole string. The lazy version, <b>.*?</b>, returns two matches: <b>x</b> and <b>y</b>. When the Highlighted panel shows one long match where you expected several, a greedy quantifier is the usual cause.
Capture groups are listed in order, separated by a vertical bar. A group that did not take part in a match shows as an empty value. For example, (a)|(b) run against ab gives groups: a | (empty) for the first match and (empty) | b for the second. Named groups such as (?<year>\d{4}) work, but they are listed by position rather than by name.
Common use cases
- Building and checking validation rules for form fields such as emails, phone numbers and postal codes
- Extracting IDs, timestamps or error codes from log lines
- Writing patterns for test assertions and log-based checks in automation frameworks
- Debugging a regex that matches too much, too little, or nothing at all
- Checking how the m, s and u flags change behavior on multi-line or Unicode input
FAQ
Which regex flavor does this tester use?
The JavaScript (ECMAScript) engine built into your browser, so results match JavaScript and Node.js. Syntax specific to PCRE, Python or .NET, such as possessive quantifiers or inline modifiers like (?i), may be rejected or behave differently.
Why do I get no matches when the pattern looks right?
Check whether you need the i flag for case, or the m flag for ^ and $ on each line. Also note that the pattern field takes a raw pattern, so do not wrap it in slashes or double the backslashes the way you would inside a string literal.
Are capture groups shown?
Yes. Each match lists its captured group values in order, alongside the full match and its index. Groups that did not participate show as empty.
Does the tester support find and replace?
No. It highlights and lists matches only. Check your pattern here, then use it with String.prototype.replace in your code.
What does the s flag do in JavaScript regex?
It enables dotAll mode, so . also matches line breaks. Without s, . matches any character except newline characters.
Is there a match limit?
The first 500 matches are displayed and counted. That keeps the page responsive on large inputs or patterns that match very often.
Is my test text uploaded anywhere?
No. Matching runs entirely in your browser, and nothing is sent to a server.