Test patterns live with the Regex Tester — match indices, groups, and flags, all in your browser.
Why test regex in the browser
Regexes appear in input validation, log parsing, and CI pipelines. When one misbehaves, the fastest way to understand it is to see the matches against real input.
Online regex tools send your pattern and test text to their servers. For logs, configs, or test fixtures containing sensitive values, that is a leak you do not need. A client-side tester runs the same JavaScript RegExp engine locally.
This page's tester uses the native RegExp engine, so what you see is what Node.js and the browser will do.
The flags that change everything
Flags alter matching semantics in ways that are easy to overlook:
g returns all matches instead of the first one. i ignores case. m makes ^ and $ match at line boundaries. s lets . match newlines. u enables Unicode-aware matching, so \p{L} and astral characters behave correctly.
- g: find every match, not just the first
- i: case-insensitive matching
- m: ^ and $ match at the start and end of each line
- s: dot matches newline characters
- u: Unicode mode for \p{...} properties and astral code points
Groups: capture what you actually need
Parentheses capture groups for later use. Numbered groups are assigned in order; named groups like (?<year>\d{4}) make the extraction readable.
Non-capturing groups (?:...) group without capturing. Use them when you only need alternation or quantifiers applied to a block, to avoid shifting group numbers.
The tester shows every group per match, named or numbered, so you can verify extraction before writing it into code.
Lookarounds and anchors
Lookahead (?=...) asserts what follows without consuming it; negative lookahead (?!...) asserts what does not follow. Lookbehind (?<=...) and negative lookbehind (?<!...) do the same for what precedes the match.
Anchors ^ and $ pin the match to the string (or line, with m). Word boundary \b matches between a word character and a non-word character.
Keep lookarounds simple. Nested lookarounds and heavy alternation inside them are where patterns become unreadable and slow.
Warning: On untrusted input, avoid nested quantifiers like (a+)+ or patterns with ambiguous alternation. They can trigger catastrophic backtracking and hang your application.
A safe regex workflow
- Open the Regex Tester in your browser.
- Paste the pattern and select the flags your runtime uses.
- Add a small sample that represents the real input, including edge cases.
- Read the matches and groups; if the extraction is wrong, fix the pattern before touching code.
- Copy the verified pattern into your code, and keep the same flags.
FAQ
Q.Is my pattern uploaded when I test it?
A.No. The tester runs entirely in your browser with the native RegExp engine. Your pattern and test text never leave your device.
Q.Which regex flavor does this tool use?
A.JavaScript's native RegExp, the same engine used by Node.js and modern browsers. If your code runs on that engine, behavior matches exactly.
Q.Why does my pattern hang or run slowly?
A.Catastrophic backtracking, usually from nested quantifiers like (a+)+ or long alternations applied to large inputs. Simplify the pattern, add anchors, and test with realistic input sizes.
Q.How do I match non-ASCII characters?
A.Use the u flag and Unicode property escapes like \p{L} for letters or \p{Script=Greek}. Without u, JS treats the pattern as UTF-16 code units and astral characters can break matching.
References
This guide is based on the JavaScript language specification and common regex practice:
- MDN – Regular expressions: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
- ECMAScript Language Specification – RegExp: https://tc39.es/ecma262/#sec-regexp-regular-expression-objects
- OWASP – ReDoS (Regular Expression Denial of Service): https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
Read the matches before rewriting the pattern
Most regex bugs are visible in the output: a missing flag, an extra greedy quantifier, or a group in the wrong position. Testing locally shows all of it without leaking your input.
Run your patterns through the Regex Tester, keep the flags identical in code, and test edge cases before deployment.