Regex Tester for JavaScript Regular Expressions
Try a regex on sample text and see every match and group.
Use via API
Run a JavaScript regular expression against text: every match with its position and capture groups, an optional replacement result, and a plain-English explanation of the pattern. Runs are time-limited. Send JSON, get JSON back.
POST https://pithlab.com/api/v1/tools/regex-tester
curl https://pithlab.com/api/v1/tools/regex-tester \
-H "Authorization: Bearer $PITHLAB_KEY" \
-H "Content-Type: application/json" \
-d '{"pattern":"(?<year>\\d{4})-(?<month>\\d{2})","flags":"g","text":"Released 2024-03, updated 2025-11.","replacement":"$<month>/$<year>"}'About the Regex Tester
Test JavaScript regular expressions live: highlight every match, inspect numbered and named capture groups, toggle flags and preview replacements in your browser.
How to use the Regex Tester
- Enter a pattern without the surrounding slashes, for example \d{3}-\d{4}. A plain-English explanation of each part appears below it.
- Tick the flags you need. Without g (global) only the first match is found, exactly as in JavaScript.
- Paste your test text. Matches are highlighted and listed with their position and capture groups.
- Optionally type a replacement using $1, $<name> or $& to preview String.replace.
Examples
Input
/\d+/g on Order 66 shipped 3 items for £120
Output
66, 3, 120
Input
/\bcat\w*/gi on Cats and a catalogue, not a bobcat
Output
Cats, catalogue
Frequently asked questions
Which regex flavour does this use?
Your browser's own JavaScript RegExp engine, so results match what your JavaScript or TypeScript code will do. Features from other flavours, such as possessive quantifiers or PCRE recursion, are not supported.
What do the flags mean?
g finds all matches, i ignores case, m makes ^ and $ match at line breaks, s lets . match newlines, u enables full Unicode mode, v enables Unicode sets, y (sticky) matches only at the current position, and d records match indices.
Why does my pattern freeze the page?
Some patterns, such as (a+)+$ on a long non-matching string, cause catastrophic backtracking that takes exponential time in any backtracking engine. The tool limits listed matches to 1,000 but cannot interrupt a single runaway match, so simplify nested quantifiers.
How are empty matches handled?
Like JavaScript's matchAll: a zero-length match is recorded and the search moves forward one character, so patterns such as \b or x* list every position they match.