Skip to content
ToolBoxGenie

Regex Tester

Developer Tools · Added 15 July 2026

Write a pattern, paste some test text, and see every match highlighted as you type. Capture groups are listed per match with their positions, flags are toggled with checkboxes, and a replace field previews the substitution.

No surrounding slashes needed. This is the JavaScript regex flavour.

Flags

How to use the regex tester

  1. 1Enter your pattern — no surrounding slashes needed.
  2. 2Toggle the flags you want: global, case-insensitive, multiline, dot-all, unicode.
  3. 3Paste test text underneath; matches highlight immediately.
  4. 4Add a replacement string to preview the result of a replace operation.

Examples

Extracting years

Input
Pattern \b(19|20)\d{2}\b against a paragraph of prose
Result
Every four-digit year highlighted, with the century captured in group 1

Reformatting with groups

Input
Pattern (\w+)@(\w+)\.com, replacement $1 at $2
Result
ada@example.com becomes ada at example

About the regex tester

Building a pattern incrementally

The reliable way to write a regular expression is to start with the simplest thing that matches one example and tighten it. Match the literal text first, then replace the parts that vary with character classes, then add quantifiers, then add anchors.

Testing against text that should not match is just as important as testing text that should. A pattern that matches everything you feed it is usually broken in a way you will not discover until production.

Use named groups and comments

Named capture groups — (?<year>\d{4}) — cost nothing and make both the pattern and the code that consumes it readable. Referring to match.groups.year beats match[3], particularly after someone inserts a group in the middle.

And know when to stop. Regular expressions cannot parse nested structures such as HTML or JSON, because those are not regular languages. If your pattern is growing lookaheads to handle nesting, reach for a real parser instead.

Frequently asked questions

Which regex flavour is this?
JavaScript's, running in your browser. It is close to PCRE for everyday patterns, but there are differences: no atomic groups or possessive quantifiers, and lookbehind requires a reasonably modern browser. Patterns written for Python or PHP usually transfer with minor edits.
What does the global flag change?
Without it, only the first match is returned. With it, the engine continues scanning after each match. This page always finds every match for display, but the flag still affects how a replace behaves — a non-global replace changes only the first occurrence.
Why does my pattern hang the page?
Catastrophic backtracking. Nested quantifiers such as (a+)+ can force the engine to try an exponential number of paths on a non-matching input. Avoid nesting quantifiers, and prefer specific character classes over dot-star wherever possible.
Can I use this to validate email addresses?
You can, but you probably should not. The full grammar for a valid address is far more permissive than any readable pattern, and a strict regex mostly rejects real addresses. Check for a single @ with something either side, then send a confirmation email — that is the only real validation.