Regex Tester (JavaScript Flavor)
Test a JavaScript regular expression against sample text, list every match with its index, and preview a replacement. Enter a pattern and flags (g, i, m, s, u, y), then run or replace. The tool is client-side, uses your browser's own RegExp engine, and never sends your data anywhere.
Quick cheat sheet
\ddigit,\wword character,\swhitespace; uppercase forms negate them..any character except line breaks unless thesflag is set.^start,$end; withmthey match each line.*zero or more,+one or more,?zero or one,{2,4}a range.[abc]one of those characters,[^abc]anything else,(...)a capture group.(?<name>...)a named group,(?:...)a non-capturing group,(?=...)a lookahead.\ba word boundary;\escapes a metacharacter.
JavaScript RegExp only. Matching adds g internally; Replace uses your flags exactly. A pathological pattern can still freeze the tab.
How to test a JavaScript regular expression
Type a pattern without the surrounding slashes, set the flags, and paste the text you want to test. Run matches scans the text and lists each result with its zero-based character index, its capture groups, and any named groups. The listing adds the g flag internally so you see every match rather than only the first one. Replace performs a real String.replace call with your flags exactly as written, which means that without g only the first match is replaced. Replacement strings can use $1, $&, $`, $', and $<name> according to JavaScript rules.
The supported flags are g (global), i (case-insensitive), m (multiline), s (dotAll), u (Unicode mode), and y (sticky). Unsupported letters and repeated flags are rejected with a message. This is the JavaScript flavor, so it is not a PCRE, Python, Java, or .NET tester. Constructs such as possessive quantifiers, atomic groups, and PCRE-only escapes will fail or mean something different. Named groups and lookbehind work only when the browser engine supports them; modern browsers do.
Regular expressions can backtrack explosively. A short pattern with nested quantifiers, such as one that repeats a group that itself repeats, can take an enormous number of steps on the wrong input. JavaScript cannot interrupt a running RegExp call, so this tool cannot enforce a timeout. It does cap the pattern at 1000 characters, the test text at 200000 characters, and the match list at 5000 entries, but those caps do not prevent all slowdowns. Keep the sample small while you refine a pattern, and avoid running an untrusted pattern on a large document.
Zero-length matches are advanced by one position so the match loop cannot spin forever. If a pattern can match an empty string, expect repeated hits at adjacent positions; that is normal JavaScript behavior. Everything runs in the page using the browser's own engine, so the text never leaves your device.
FAQ
Which regex flavor does this tester use?
It uses the JavaScript RegExp engine built into your browser. Patterns written for PCRE, Python, Java, .NET, or other engines may behave differently or fail to compile.
Which flags can I use?
The supported flags are g for global, i for case-insensitive, m for multiline, s for dotAll, u for Unicode mode, and y for sticky. Unsupported or duplicate flags produce an error.
Why do I get all matches even without the g flag?
Match listing adds the g flag internally so every result can be shown. The replace action follows your flags exactly, so without g it replaces only the first match.
Can a bad pattern freeze the page?
Possibly. JavaScript RegExp runs synchronously and cannot be interrupted. The tool limits the pattern to 1000 characters, the test text to 200000 characters, and the match list to 5000 entries, but a pathological backtracking pattern can still hang the tab. Keep the test text small while you experiment.
Does it support lookbehind and named groups?
Named groups and lookbehind work in current browsers that implement them in the JavaScript engine. Very old browsers may reject those constructs, and the tool will show the engine error.
Is the text I paste uploaded?
No. Matching and replacing run locally with your browser's RegExp object. Nothing is sent to a server and no account is needed.