JavaScript Regex Tester
Test JavaScript regular expressions online with live highlighted matches, capture and named groups, flags and a replace preview.
How to use it
Enter a pattern, tick the flags you need and type some test text. Matches are highlighted and listed with their groups; tick Replace to preview a replacement using $1 or $<name>.
About this tool
This tester uses your browser's own JavaScript regular expression engine, so results match what the same pattern does in JavaScript code. Patterns for other languages such as PCRE or Python can differ in syntax and flags.
Frequently asked questions
- Which regex flavour does it use?
- JavaScript (ECMAScript), the engine built into your browser. Lookbehind and named groups work in current browsers; features that are specific to PCRE or Python, such as possessive quantifiers, do not.
- How do I see capture groups?
- Matches are listed with each numbered and named capture group underneath. Named groups use the syntax (?<name>...).
- What do the flags do?
- g finds every match instead of the first, i ignores case, m makes ^ and $ match at each line, s lets . match newlines, u turns on Unicode mode and y matches only at the last index.
- How do I test a replacement?
- Tick Replace and enter a replacement. Use $1 for a numbered group, $<name> for a named group and $& for the whole match.