TTKTheTextKit
Developer & Web Tools

Regex Tester

Enter a regular expression pattern, select flags (g, i, m, s), and paste a test string. All matches are highlighted inline, and each match's captured groups are listed below. Invalid patterns show a descriptive error instead of crashing. All processing is local — your patterns and strings stay in the browser.

//g

Related Tools

[3 suggestions]

About the Regex Tester

The Regex Tester constructs a JavaScript RegExp object from your pattern and selected flags, then uses matchAll() to collect every match and its captured groups when the global (g) flag is active, or exec() for a single match. Matches are highlighted by splitting the test string at match boundaries and wrapping matching segments in styled spans — no DOM manipulation or contenteditable tricks, just pure React rendering. The flags panel exposes the four most useful flags: g (find all matches, not just the first), i (case-insensitive matching), m (multiline — ^ and $ match line boundaries), and s (dotAll — . matches newlines). Invalid regex patterns (unbalanced brackets, invalid escape sequences, etc.) throw a SyntaxError on construction, which the tool catches and displays as a friendly error message so your test string stays visible and editable. Developers use this to write and debug validation patterns (email, phone, postal codes), to build text extraction pipelines, and to test search-and-replace expressions before applying them in an editor or script.

What regex flags are supported?▾

The tester supports four flags: g (global — find all matches), i (case-insensitive), m (multiline — ^ and $ match line starts/ends), and s (dotAll — makes . match newline characters too).

How are capture groups shown?▾

For each match, the tool lists every numbered capture group (the parts of the pattern in parentheses). Named capture groups ((?<name>...)) are shown with their names. Unmatched optional groups show as "empty".

What happens if my pattern is invalid?▾

If the RegExp constructor throws a SyntaxError (e.g. unbalanced brackets or an invalid escape), the tool displays the error message in red below the pattern field without clearing your test string.