consolelog.tools

Regex Tester

Test regular expressions live — highlighted matches, numbered & named capture groups, per-match line:column, and a replacement preview.

About this ToolHow it works, benefits & use cases

The Regex Tester (regular expression tester) evaluates a JavaScript regular expression against your test string and shows the results the moment you type. Enter a pattern and flags (any combination of g, i, m, s, u, v, y), paste the text to match, and the tool highlights every match inline and lists each one with its character index and a line:column position. For patterns with capture groups it breaks out the numbered groups ($1, $2, …) and any named groups (?<name>...) per match, so you can verify your captures are landing where you expect. An optional replacement field runs String.replace live and shows the rewritten output, letting you preview substitutions with $1 or $<name> references before using them in code. Invalid patterns and bad flags surface a clear error message instead of throwing. Evaluation is debounced and happens entirely in your browser — nothing is uploaded, and it is free to use.

How to Use

  1. 1Type your regular expression into the Pattern field, or click "Load example" for a working named-group sample.
  2. 2Set the Flags (for example g for global, i for case-insensitive, m for multiline) in the small flags field.
  3. 3Paste the text to match into the Test string panel — matches highlight and update live as you type.
  4. 4Optionally enter a Replacement (using $1, $<name>, or literal text) to preview a String.replace result.
  5. 5Review the highlighted matches, the numbered and named capture groups, and the per-match line:column under "Matches".

Key Benefits

  • Live, debounced matching highlights every hit as you type
  • Per-match index plus line:column makes locating matches in multiline text easy
  • Breaks out both numbered ($1) and named (?<name>) capture groups for each match
  • Optional replacement field previews String.replace output with $1 / $<name> references
  • Supports all JavaScript flags: g, i, m, s, u, v, and y
  • Clear, non-throwing error messages for invalid patterns or flags
  • Safe against zero-length-match infinite loops; runs entirely in-browser

Common Use Cases

  • Debugging a validation or parsing regex before pasting it into application code
  • Confirming that named capture groups extract the right substrings
  • Prototyping a find-and-replace transformation with a live preview
  • Counting and locating every occurrence of a pattern in a log or text dump
  • Learning regex syntax and flag behavior with instant visual feedback

Pattern

Live preview of String.replace with this pattern

Live evaluation — matches update as you type.

Was this tool helpful?

Share Your Experience

Help others discover this tool!

Related guides

Related tools