Utilities Processed locally

Regex Tester

Test a JavaScript regular expression against a sample string — every match with its position, capture groups, and named groups, live as you type. Toggle flags (g / i / m / s / u / y), or paste a /pattern/flags literal. The Groups tab describes captures; Code emits the pattern for 8 languages; a ReDoS heuristic warns about catastrophic backtracking. Runs in your browser.

Pattern & test string
Flags:
Advanced regex flags

Auto-runs as you type. Test · Extract · Replace (preview) · Split. Ctrl+Enter to re-run.

Guide & FAQ

Build, test, debug, and explain JavaScript regular expressions against your sample text. The Regex Tester highlights matches, lists capture and named groups, lets you preview replacements safely, splits on a pattern, flags ReDoS risk in your expression, and exports matches as CSV or JSON. Useful for writing log parsers, extracting fields, validating inputs, and learning regex — and it runs entirely in your browser.

What it does
  • Tests a regex against sample text with live highlighting.
  • Supports JavaScript flags: g (global), i (case-insensitive), m (multiline), s (dotAll), u (unicode), y (sticky), d (indices).
  • Inspects capture groups, named groups ((?<name>...)), and per-match line / column positions.
  • Extract, Replace (with preview diff), and Split modes.
  • ReDoS / performance safety check for catastrophic-backtracking patterns.
  • Imports patterns in /pattern/flags form copied from other languages.
  • Exports matches as CSV or JSON and hands off to Line Tools, JSON Formatter, PII Detector, and more.
When to use it
  • Build a log-parsing regex and confirm it captures the right fields.
  • Extract emails, URLs, IDs, or IPs from a block of text.
  • Validate an input pattern (email, phone, postcode) before shipping it.
  • Preview a replace operation safely before running it against a real file.
  • Debug a regex copied from a config or a third-party rule (Datadog, Logstash, fail2ban).
  • Learn regex by stepping through groups and explanations.
How to use it
  1. Paste your sample text into the input.
  2. Enter the regex pattern — either raw, or /pattern/flags from another language.
  3. Toggle flags (g, i, m, s, etc.) and click Test Regex — matches are highlighted in the text.
  4. Inspect the Groups / Matches tab to see every match, capture group, and position.
  5. Switch to Extract for a clean list, Replace for a preview diff, or Split to break the text on the pattern.
  6. Open the Performance / Safety tab to see ReDoS warnings before deploying the regex.
  7. Export matches as CSV or JSON for downstream work.
Capture & named groups

Use plain groups (...), named groups (?<id>...), and non-capturing groups (?:...). The Groups / Matches tab shows every group's value, start/end, and whether it matched. With the d flag, group start/end indices are returned by the engine.

Tips & pitfalls
  • Forgotten g flag is the #1 reason "find all" returns only the first match.
  • . does not match newlines unless you add the s (dotAll) flag.
  • Escape regex metacharacters (. + * ? ( ) [ ] { } | \) when matching them literally.
  • Avoid catastrophic backtracking: (a+)+, (.*)+, and similar nested quantifiers — the Safety tab flags these.
  • For structured data (JSON, XML), use JSONPath or XPath — regex is fragile against structure changes.
  • JavaScript regex differs from PCRE / Python / Java around lookbehind, recursion, and certain shorthands.
ReDoS & performance safety

Some regex shapes — nested quantifiers like (a+)+, repeated groups like ([a-z]+)*, ambiguous alternation, leading .* with backtracking — can cause exponential matching time. The Performance / Safety tab flags these heuristically. The engine also caps matches and execution time so a risky pattern cannot freeze the browser.

FAQ

FAQ

  • Does this upload my text? No — JavaScript RegExp runs entirely in your browser.
  • Which engine is used? Your browser's JavaScript RegExp. Behavior may differ from PCRE, Python, Java, .NET, or RE2 — especially around lookbehind, named groups, and backtracking.
  • How do I extract all matches? Add the g flag and run, or use the Extract tab.
  • How do I preview replacements safely? The Replace tab shows replaced output and a colored before/after diff before you copy it out.
  • Why does dot not match newlines? JavaScript's . excludes line terminators unless you set the s (dotAll) flag.
  • Can I export matches as CSV or JSON? Yes — use the Exports tab or the Extract tab.
  • Why does my pattern not match the expected substring? Common causes: missing g, missing i, missing s for multi-line matching, and forgotten escaping of literal characters.
  • When should I use JSONPath / XPath instead? For structured documents (JSON / XML), prefer JSONPath or XPath — regex is fragile against structure changes.
  • What is ReDoS? Regular-expression Denial of Service — input crafted to trigger exponential backtracking. The Safety tab flags patterns vulnerable to it.
Related guides

Runs locally in your browser. No uploads. Sample text, pattern, and outputs are never sent to a server.