Developer Tools

Regex Tester

Test a regular expression with live highlighting, groups, a plain-English explanation and ready-made patterns.

By Nitin Raturi · Last reviewed

Input

How to use the Regex Tester

Write a pattern, see every match highlighted, and read what each part means.

  1. Pick a common pattern, or type your own.
  2. Paste the text to search.
  3. Turn flags on or off: g, i, m and s.
  4. Read the highlighted matches, the groups and the plain-English explanation.
  5. Optionally type a replacement to preview a find-and-replace.

Good to know

  • A pattern that takes too long is stopped after a moment instead of freezing the page.
  • Tap the ⓘ next to any field for a short guide to it.

Uses your browser’s JavaScript RegExp engine. Matches are highlighted as you type.

Runs in your browser. Nothing you type is uploaded or saved in the link.

Start from a common pattern

Fills in a ready-made pattern and sample text that you can then change.

How to fill it in

  • Pick one to learn from or adapt. Each shows what it checks and what it does not.

Ten digits starting 6–9. Checks the shape only, not that the number exists.

Pattern

The regular expression, written as you would put it between slashes in JavaScript.

How to fill it in

  • Type it without the surrounding slashes, for example \d{3}.
  • This uses your browser’s JavaScript engine, so other languages may differ slightly.

Example

\b[6-9]\d{9}\b finds 2 matches in the mobile-number sample.

g: find all matches

Global: keeps searching after the first match.

How to fill it in

  • Turn it off to see only the first match.

i: ignore case

Treats capital and small letters as the same.

How to fill it in

  • Turn it on so “cat” also matches “Cat” and “CAT”.

m: multiline

Makes ^ and $ match at the start and end of each line, not only of the whole text.

How to fill it in

  • Turn it on when checking text line by line.

s: dot matches line breaks

Lets . match a line break as well as any other character.

How to fill it in

  • Turn it on to match across lines.

Test text

The text the pattern is run against. Matches are highlighted as you type.

How to fill it in

  • Paste anything; it stays in your browser.

Replace with

Optional text that replaces each match, to preview a find-and-replace.

How to fill it in

  • Use $1, $2 for numbered groups and $<name> for named groups. Leave it empty to skip.

Result

2 matches

Highlighted text

Call 9876543210 or 1234567890 or 7012345678

Match 1 at 5
"9876543210"
Match 2 at 33
"7012345678"
What the pattern means
\b
a word boundary
[6-9]
one character from [6-9]
\d{9}
a digit 0–9, exactly 9 times
\b
a word boundary

How this calculator works

  1. Step 1Compile the patternJavaScript RegExpThe same engine your browser and Node.js use.
  2. Step 2Search in the backgroundTime limitSlow patterns are stopped instead of freezing the page.
  3. Step 3Show and explainHighlightsEvery match, every group, and what each token means.

A regular expression is a small pattern language for finding text. Different languages share most of the syntax, but details such as lookbehind and named groups vary.

Worked example: an Indian mobile number

\b[6-9]\d{9}\b finds 2 numbers in the sample text: 9876543210 and 7012345678.

Reading the pattern token by token
Pattern
\b[6-9]\d{9}\b
  1. \ba word boundary
  2. [6-9]one character from [6-9]
  3. \d{9}a digit 0–9, exactly 9 times
  4. \ba word boundary
  5. Matches in the sample9876543210 at 5, 7012345678 at 33

“1234567890” is skipped because it starts with 1. The pattern checks only the shape of a number, not whether the number is in use.

Reading the result

  • Without gFirst match onlyThe search stops after the first match.
  • With gEvery matchThe search continues to the end of the text.
  • HighlightsMatched text is marked and underlined in place.
  • GroupsNumbered and named groups for each match.
  • ExplanationA plain-English meaning for each token.
  • Time limitPatterns that run too long are stopped with a message.

A regular expression finds patterns. Other tools clean, compare and reshape text.

To compare two texts line by line, use the diff checker. The remove duplicate lines tool tidies lists, and the case converter changes text to camelCase, snake_case and more.

Common mistakes

  • Mistake: Forgetting to escape a dot in a domain or price.

    Instead: Write \. to match a real full stop.

  • Mistake: Nesting repeats such as (a+)+.

    Instead: Make each repeat specific; nested repeats can take exponential time.

  • Mistake: Using a regex to fully validate email or dates.

    Instead: Use it for shape, then check the value in code.

  • Mistake: Leaving out ^ and $ when the whole input must match.

    Instead: Anchor the pattern, or a match inside longer text counts.

Read how we test our calculators, or browse more developer tools.

Frequently asked questions

Which regex flavour does this use?

JavaScript, as built into your browser. Most syntax works the same in Python, Java and PHP, but features such as lookbehind and named groups differ in places.

Why was my pattern stopped?

Some patterns, especially nested repeats like (a+)+, can take exponential time on certain text. The tester stops any search that runs longer than 1.5 seconds.

How do I use groups in the replacement?

Use $1, $2 and so on for numbered groups, $<name> for named groups and $& for the whole match.

Does the mobile-number pattern check that a number is real?

No. It checks only the shape: ten digits starting with 6, 7, 8 or 9. A regex cannot tell whether a number is in use.

Is my text uploaded?

No. Matching runs in your browser. The pattern and text are not saved in the link; only the flags and preset are.

Sources and methodology

The formulas are standard time-value-of-money results. We check every figure against golden values worked out independently, by closed form and by month-by-month simulation; see the methodology.

Written and maintained by Nitin Raturi, a software engineer (about the author). Last reviewed 27 Oct 2026; next review due by . Found an error? Tell us.

Changelog

  • : Initial release. Demand metrics remain unverified.