What this tester does
Your pattern is passed straight to the browser's own JavaScript RegExp engine, so what matches here will match in any JavaScript or TypeScript code on the same browser. The page finds every match in the test string, shows how many there are, highlights each one, and lists the numbered and named capture groups of every match. It has no replace step. To transform text with a pattern, use find and replace, which has a regex option.
Flags
| Flag | Effect |
|---|---|
g | Global, on by default. Untick it to see only the first match. |
i | Ignore case |
m | ^ and $ match at each line, not just the whole string |
s | . also matches line breaks |
u | Unicode mode: handles characters beyond the basic plane and rejects sloppy escapes |
v | Unicode sets mode, a stricter upgrade of u (set operations and string properties). Replaces u when ticked. Shown only if your browser supports it. |
y | Sticky: a match must start exactly where the search position is, so with g it finds only back-to-back matches from the start |
d | Match indices, accepted for completeness. Shown only if your browser supports it. |
Worked example
Pattern \d{4}-\d{2}-\d{2} with the global flag, tested on Due 2024-03-15 and 2025-01-09., reports 2 matches and highlights 2024-03-15 and 2025-01-09. Make it (?<year>\d{4})-(?<month>\d{2}) and the match list shows, for each hit, the full match plus group 1: 2024, group 2: 03 and the named groups year and month. Untick g and only the first match is reported.
Gotchas
- Type the pattern without slashes. The field shows the surrounding
/characters itself, and you should not write/\d+/gor double the backslashes as you would inside a string literal. - Other engines differ. A pattern from PCRE, Python or PHP may use possessive quantifiers, atomic groups or inline flags like
(?i). JavaScript lacks those, and the tester will report "Invalid regex". - Greedy by default.
<.+>swallows everything between the first<and the last>on a line. Add?to make it lazy. - Catastrophic backtracking. A nested quantifier such as
(a+)+$on a long near-miss string can take exponential time. Matching runs in a background worker that is stopped after one second, and the page then shows "Pattern took too long" so the tab stays usable. Simplify the pattern or shorten the text. - Zero-length matches, such as
x*, are counted and can inflate the total. They are listed as (empty) and are not highlighted. At most 5000 matches are counted, and the first 100 are listed.
The regex cheat sheet lists character classes, quantifiers and ready-made patterns that you can paste in and try.