Regex Tester

Test regular expressions with live match highlighting, flags, and captured groups.

/ /

📐 How to Use

  1. Enter your regular expression in the pattern field.
  2. Select flags (g = global, i = case insensitive, m = multiline, s = dotAll).
  3. Type or paste your test string — matches highlight live.
  4. Scroll down to see each match with its index and any captured groups.

🎯 When to Use This

  • Working out a log-parsing pattern before committing it, with the index of each match showing exactly where the engine started and stopped.
  • Checking that a validation regex copied from an answer site does not quietly match more than you intended on real sample data.
  • Naming capture groups while building an extraction rule, so the match list tells you which name ended up holding which fragment.
  • Confirming how a pattern behaves with and without the multiline flag, by toggling the checkbox and watching the match count change.

❓ Frequently Asked Questions

QWhat regex flavour does this use?
JavaScript's built-in RegExp engine, which follows the ECMAScript standard. It supports most common regex features including lookaheads, named groups, and Unicode.
QWhat does the "g" flag do?
Without the global flag, only the first match is found. With "g", all matches in the string are highlighted.
QCan I test named capture groups?
Yes — named groups like (?<year>\d{4}) are supported and displayed in the match details.

ℹ️ About This Tool

A regular expression is a small program. The engine walks the input and, at each point where the pattern offers a choice, remembers where it was so it can come back and try the other branch. That backtracking is what makes alternation and quantifiers work, and it is also why a pattern can take exponential time on input that nearly matches. JavaScript's flavor is its own dialect: it has lookbehind and named groups, but no possessive quantifiers, no atomic groups and no recursion.

Patterns here are compiled with the browser's RegExp constructor from your pattern plus the g, i, m and s checkboxes, and the global flag is added internally so every occurrence is collected. Matches come from repeated exec() calls and are listed with their start index, numbered groups and named groups. Highlighting is a second layer painted behind a transparent textarea rather than a rewrite of your text.

⚠️ Notes & Limits

  • A pattern that can match an empty string, such as a* or \b, makes the match loop run forever and freezes the tab. Require at least one character.
  • Only the g, i, m and s flags are offered. The unicode flags u and v and the sticky flag y are absent, so escapes like \p{L} will not compile.
  • This is the ECMAScript engine. Patterns written for PCRE, Python or Go may use syntax it rejects, and \A, \z and possessive quantifiers have no equivalent.
  • Nested quantifiers can backtrack for a very long time on a long test string, and nothing on the page times the attempt out or cancels it.