Regex Tester
A small test sample can reveal whether a pattern matches too much, too little or nothing at all. Enter JavaScript regex syntax without the surrounding slash delimiters, then list matched text, offsets and capture groups. The global flag controls whether the tester continues after the first match. Matching runs in a separate worker with a time limit, so a pattern with excessive backtracking does not lock the page. Results use JavaScript string indexes, which count UTF-16 code units rather than visual characters.
Your workspace
Runs locally in your browserResult
Your input is processed locally in your browser unless explicitly stated otherwise. Inputs are not saved by this tool.
How to use this tool
Enter a pattern without surrounding slashes, choose flags, and supply test text. Select Test to list match positions and captures.
Example
Input
Pattern: \bcat\b | Text: a cat and a catOutput
2 matches: cat at index 2; cat at index 12What does this tool do?
Regular expressions describe patterns in text. This tester uses the JavaScript RegExp engine, so its behavior may differ from PCRE, Python or database engines.
Common mistakes and limitations
g finds all matches; i ignores case; m changes line anchors; s lets dot match newlines; u enables Unicode mode. Expensive patterns are stopped after a short timeout. Output is capped at 1,000 matches.
Start with a small matching example
A literal character usually matches itself, a character class such as [0-9] matches one listed character, and a quantifier controls repetition. The + quantifier means one or more, * means zero or more, and {2,4} supplies a range. Parentheses capture a group unless you use a non-capturing form. Begin with text that should match and text that should not; a pattern that matches one happy-path sample is not necessarily a useful validator.
Pattern: ^([A-Z]{2})-([0-9]{3})$
Text: AB-123
Groups: AB and 123Flags, anchors and escaping
The i flag ignores case, g searches for multiple matches, m changes line-anchor behavior, and s allows a dot to match line terminators. A caret and dollar anchor a pattern to boundaries according to its flags; they do not make every possible Unicode input safe. Enter the pattern itself here without JavaScript slash delimiters. A literal dot needs a backslash. If you later place that same pattern inside a JavaScript string, the string layer may require another backslash.
JavaScript flavor and costly patterns
This tester uses the browser’s JavaScript RegExp implementation. Syntax from PCRE, Python or a database regex engine may behave differently or be rejected. Nested ambiguous repetition can cause excessive backtracking, so testing runs in a disposable worker with a timeout. A timeout is a reason to simplify the pattern, not to raise the limit indefinitely. Matching untrusted large text in production still needs input limits and careful pattern design. Empty matches also need special handling when iterating.
Build a small regression set
After finding a pattern, test empty input, leading and trailing whitespace, repeated delimiters and non-ASCII text. Include near misses rather than only valid examples. If the pattern will run in another environment, repeat those examples in that exact engine. Regex can be useful for a simple shape, but parsing JSON, HTML or a complex protocol with a single pattern often misses nesting and escaping rules.
Frequently asked questions
Why does another language produce different matches?
Regex engines have different syntax and Unicode rules. Test the expression in the runtime where it will be used.
Related tools
JavaScript Minifier
Minify JavaScript locally with Terser without evaluating the supplied code.
Open tool Developer ToolsJSON Formatter & Validator
Format and validate JSON with readable indentation.
Open tool Encoding & ConversionURL Encoder & Decoder
Encode or decode a URL component safely.
Open tool