Regex Tester
Test JavaScript regular expressions against sample text with inline match highlighting, capture groups, named groups, and a replace preview.
Processed locally in your browser — nothing is uploaded.
Regex Tester
0 characters
About Regex Tester
Write a pattern, pick flags, and see every match highlighted in your test string as you type. Each match is listed with its index, numbered capture groups, and named groups from (?<name>…) syntax. Invalid patterns show the exact engine error instead of failing silently.
Replace mode previews the result of .replace() with a template, including $1, $<name>, and $& references — handy for checking a substitution before it goes into code.
Common uses
- Debug why a pattern matches too much or too little
- Extract capture groups from sample log lines
- Preview a search-and-replace before running it across a codebase
Example
Input
pattern (?<year>\d{4}) against "born 1815"Output
1 match · year: 1815
Limitations
- Uses your browser's JavaScript regex engine — PCRE-only syntax (possessive quantifiers, recursion) won't work
- Without the g flag only the first match is reported, mirroring JavaScript semantics
Frequently asked questions
Why does my regex only find the first match?
You are missing the g (global) flag. Without it JavaScript stops after the first match, and this tool mirrors that behavior exactly so results match what your code will do — add g to the flags field to find every occurrence.
Is the text I test my regex against sent anywhere?
No. Matching runs in your browser's own JavaScript engine and nothing is uploaded, so pasting production log lines or user data to debug a pattern is safe.
Does this tester support PCRE features like possessive quantifiers?
No. It uses the JavaScript regex engine, so PCRE-only syntax such as possessive quantifiers (a++), atomic groups, and recursion throws an error. Lookahead, lookbehind, named groups, and Unicode property escapes all work in modern browsers.
How do I use a capture group in the replacement text?
Reference numbered groups as $1, $2, and so on, named groups as $<name>, and the whole match as $&. Replace mode previews the exact output of JavaScript's .replace() with your template before you commit it to code.
What do the regex flags g, i, and m mean?
g finds all matches instead of stopping at the first, i makes matching case-insensitive, and m makes ^ and $ match at each line break rather than only the start and end of the whole string. JavaScript also supports s (dot matches newlines), u (Unicode mode), and y (sticky).