Regex Tester
Test and debug regular expressions instantly in your browser. Highlight matches, view capture groups, and use replace mode — free and private.
Test and debug regular expressions instantly in your browser. Highlight matches, view capture groups, and use replace mode — free and private.
Regular expressions are a domain-specific language for matching patterns in text. They have been part of computing since 1968 and are now built into every modern programming language, text editor, and command-line search tool. The syntax is concise but error-prone: small changes produce subtly different match behavior, and complex expressions become unreadable quickly. A tester that shows matches in real time as you edit the pattern is the most effective way to develop and verify regex.
This tester runs in your browser using the JavaScript regex engine (the same one your application uses if it runs in a browser). Patterns and test text update reactively: every change to either re-runs the match. Match groups are highlighted, captured groups are listed, and flags (case-insensitive, multiline, global) are exposed for testing.
Regex syntax varies subtly between engines. JavaScript follows the ECMAScript spec; Python, PCRE (used by PHP and many others), Java, and Go each have their own dialects with overlapping but not identical features. Patterns developed here use ECMAScript syntax; cross-engine portability requires checking each target's documentation.
Regex bugs are notoriously hard to debug after deployment. A pattern that looks reasonable might match more or less than intended, fail on edge cases, or have catastrophic backtracking on certain inputs. Testing patterns interactively against representative input catches issues before code review and production.
Patterns also benefit from documentation. Showing a regex alongside the input it should match and the input it should not match makes intent explicit. Future maintainers (including yourself in six months) appreciate documented test cases more than they appreciate clever one-liners.
Type a pattern, type test input, see matches highlighted live.
JavaScript regex follows the ECMAScript specification. Major features: character classes ([abc], [^abc]), quantifiers (*, +, ?, {n,m}), alternation (|), grouping ((...)), capturing and non-capturing groups, lookahead and lookbehind (modern engines), backreferences, named groups, Unicode property escapes (with u flag), and the standard set of escape sequences.
Important differences from PCRE and Python: lookbehind support is recent in JavaScript (2018+); named groups use (?<name>...) syntax; some Unicode escapes require the u flag to work correctly. Patterns intended for cross-language use should be checked against each target's documentation.
Performance: backtracking-based regex engines (most including JavaScript) can have catastrophic backtracking on certain pathological patterns. Tests that hang the tester are a sign that the pattern needs simplification — typically by avoiding nested quantifiers and ambiguous alternation.