Developer Tools

Regex Tester

Test regular expressions with live matches, capture groups, flags and replacement.

Tool

Matches

—

About the Regex Tester

The Regex Tester runs entirely in your browser — your code and data never leave your machine. Paste, click, copy the result.

Regular expressions are the shortest programming language with the steepest learning curve. This tester runs your pattern against the sample text live, lists every match with its capture groups, and lets you preview a replacement — all without leaving the page.

How to use this tool

  1. Enter the pattern (backslashes must be doubled in some inputs — the field shows standard regex).
  2. Set the flags: g global (all matches), i case-insensitive, m multiline, s dot-matches-newline.
  3. Paste your test string and press Test.
  4. Optionally enter a replacement (use $1, $2 for capture groups) to preview the result.

Cheat sheet

PatternMatches
\d / \DDigit / non-digit
\w / \WWord character / non-word
^ / $Start / end of line
[abc]+One or more of a, b or c
(…)Capture group → $1
a|bEither a or b
\bWord boundary
.*?Lazy match (as little as possible)

Practical examples

  • Email (basic): [\w.+-]+@[\w-]+\.[\w.]+
  • US phone: \(\d{3}\)\s?\d{3}-\d{4}
  • Extract numbers: -?\d+(\.\d+)?
  • Slugify: pattern [^a-z0-9]+, replace -

Who is this tool for?

Developers validating input patterns, content editors cleaning text data, and anyone who has forgotten why \d needs a double backslash.

Developer tip

Test against strings that should NOT match too — a pattern that matches everything is worse than no pattern. Start with small patterns and add complexity gradually.

Frequently asked questions

Unbalanced brackets or a lone backslash breaks it. Common fix: escape special characters twice if your environment (JSON, JS string) also processes backslashes.
Yes — patterns like (a+)+ can hang the browser on long inputs. This page will recover, but avoid nested quantifiers in production code.
JavaScript regular expressions (ECMAScript) — very close to Python and Perl, with small differences from POSIX/ERE used in grep.

Related tools

Guides for this tool