Skip to content
Toolkit home

Regex Tester & Explainer

Test regular expressions against sample text with live match highlighting and a token-by-token explanation.

Pattern
Write an expression or start from a common preset.
/gm
Flags
Matches update as you type.
Highlighted matches
Each match is highlighted in place.
3 matches
jane.doe@example.com
not-an-email@
support+billing@company.co.uk
hello@localhost
alex_92@mail.dev
Match details
Position and captured groups for each match.
  1. jane.doe@example.com#1 · index 0
  2. support+billing@company.co.uk#2 · index 35
  3. alex_92@mail.dev#3 · index 81
Explanation
A token-by-token breakdown of your pattern.
  1. ^Start of string (or line, with the m flag)
  2. [\w.+-]Any single character from: \w.+-
  3. +One or more of the previous token
  4. @The character "@"
  5. [\w-]Any single character from: \w-
  6. +One or more of the previous token
  7. \.Literal "."
  8. [\w.-]Any single character from: \w.-
  9. +One or more of the previous token
  10. $End of string (or line, with the m flag)

How the Regex Tester & Explainer works

Patterns are compiled with the JavaScript RegExp engine, the same one your browser and Node.js use, so matches here behave identically in your code. Every match is highlighted in the test string and capture groups are listed separately.

The explainer breaks the pattern into tokens such as anchors, character classes, quantifiers and groups and describes each in plain English, which makes inherited or complex expressions easier to audit.

How to use the Regex Tester & Explainer in 3 steps

  1. Step 1

    Enter a pattern or pick a preset such as Email, Phone or URL.

  2. Step 2

    Toggle the g, i, m and s flags as needed and type or paste your test text.

  3. Step 3

    Review the highlighted matches, capture groups and token-by-token explanation.

Frequently asked questions

What do the g, i, m and s regex flags do?

g finds all matches instead of the first, i ignores case, m makes ^ and $ match at line breaks, and s lets the dot match newline characters.

What is a good regex for validating email addresses?

A practical pattern is ^[^\s@]+@[^\s@]+\.[^\s@]+$, which is available as the Email preset. Fully RFC 5322-compliant patterns exist but are long; confirm addresses by sending a verification email.