Free Converter

Regex Tester

Test and debug regular expressions instantly in your browser. Highlight matches, view capture groups, and use replace mode — free and private.

//g
Flags:

About Regex Testing

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.

Why Use a Regex Tester

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.

How to Test a Regex

Type a pattern, type test input, see matches highlighted live.

  1. Enter your pattern: Type the regex pattern in the pattern field. Both literal regex (/pattern/flags) and pattern-only forms work; flags can be set via the flags input.
  2. Add test input: Paste sample text that the pattern should match (and ideally also text it should not match). The tester runs the pattern against the input and highlights matches.
  3. Set flags: Common flags: g (global, find all matches), i (case-insensitive), m (multiline, ^ and $ match line starts/ends), s (dotall, . matches newlines), u (Unicode).
  4. Inspect results: Each match is highlighted in the input. Capture groups appear in a list with group index and value. The tester also shows the count of matches and any compilation errors in the pattern.

Common Use Cases

Technical Details

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.

Best Practices

Frequently Asked Questions

Which regex flavor does the tester use?
JavaScript / ECMAScript. This matches what runs in browsers and Node.js. Patterns intended for Python, PCRE, Go, or Java may need adjustment for those engines' syntax differences.
What do the flags mean?
g (global): find all matches, not just the first. i (case-insensitive): ignore case. m (multiline): ^ and $ match line starts and ends. s (dotall): . matches newlines. u (Unicode): treat the pattern as Unicode-aware. y (sticky): match starting at lastIndex.
How do capture groups work?
Parentheses create a capturing group. Each group's matched text is available in the result, indexed from 1. Named groups (?<name>...) are accessible by name. Non-capturing groups (?:...) participate in the pattern but do not produce a captured value.
Why does my pattern run forever?
Catastrophic backtracking. Patterns with ambiguous alternation or nested quantifiers can require exponential time on certain inputs. Restructure the pattern or use possessive quantifiers / atomic groups (in engines that support them).
How do I match a literal special character?
Escape it with a backslash. To match a literal dot: \. To match a literal backslash: \\. Inside character classes [...], most special characters lose their meaning.
Is the tester running on a server?
No. Pattern compilation and matching happen in your browser using the native RegExp object.
Can I test patterns for non-JavaScript engines?
Mostly. For simple patterns the major engines agree. For advanced features (lookbehind, atomic groups, possessive quantifiers, Unicode property escapes), confirm against the target engine's documentation.
Does it handle very large input?
Up to a few megabytes works smoothly. Larger inputs may slow down or hang the browser, especially with patterns prone to backtracking.