Skip to content
TabBench

Regex Tester

Test regular expressions with live highlighting, named groups, replace and split, a plain-English explanation of the pattern, and protection from patterns that would freeze the page.

Runs in your browser. Nothing you add is uploaded.

What the Regex Tester does

Regular expressions are compact patterns for finding and validating text — an email address, a date, every number in a log — but a single misplaced character changes what they match. This tester runs your pattern against sample text as you type, highlights every match, lists each one with its position and its numbered and named capture groups, and previews replacements and splits. A line-by-line explanation says in plain English what each part of the pattern does. Patterns run in a background worker, so one that backtracks catastrophically is stopped after a moment instead of freezing the page. It uses your browser's own JavaScript regex engine, and includes ready patterns for common formats such as email, URLs, Indian mobile numbers, PIN codes, PAN, GSTIN and IFSC.

How to test a regular expression

  1. Type your pattern between the slashes, or start from one of the common patterns.
  2. Paste sample text: include text that should match and text that should not.
  3. Turn on the flags you need: g for every match, i to ignore case, m so ^ and $ work per line, s so . also matches line breaks, u for full Unicode.
  4. Check the highlighted matches, then switch to List to see each capture group, or to Replace and Split to try those operations.
  5. Read “What this pattern means” to check each part does what you intended, then copy the pattern as a JavaScript literal or new RegExp().

The Regex Tester runs entirely in your browser — nothing you enter is uploaded, stored, or logged.

When to use it

Validating form input

An Indian PIN code is six digits not starting with 0: ^[1-9][0-9]{5}$. Testing it against 560001, 056001 and 5600011 confirms it accepts the first and rejects the others before the pattern goes into your form.

Extracting data from logs

A pattern such as (\d{3}) (\d+)ms with the g flag pulls every status code and response time out of a pasted access log, with each part in its own capture group ready for your script.

Find and replace in an editor

VS Code and most editors support the same syntax. Getting the pattern and its groups right here first avoids a replace-all that rewrites the wrong lines.

Good to know

  • Anchor validation patterns with ^ and $. Without them, [0-9]{6} also matches the first six digits of a ten-digit number.
  • Quantifiers are greedy: <.+> matches from the first < to the last > on the line. Use <.+?> to stop at the nearest >.
  • Escape characters that have special meaning when you want them literally: \. for a dot, \( for a bracket, \$ for a dollar sign.
  • Patterns with nested repeats such as (a+)+ can take exponential time on long input. Keep repeats simple for anything that runs on user data.
  • Other languages differ in details — lookbehind support, named-group syntax, Unicode classes — so re-test patterns that will run outside JavaScript.

Guides that use this tool

Frequently asked questions

Which regex engine does this tool use?

It uses your browser's native ECMAScript JavaScript RegExp engine supporting standard ES2024 features.

Why does my pattern only find the first match?

Without the g (global) flag a JavaScript regex stops after the first match. Switch g on to find every occurrence in the text.

What is a capture group?

Anything inside plain round brackets is captured separately, so in (\d{4})-(\d{2}) the year is group 1 and the month is group 2. Use (?:...) when you need brackets for grouping but not a capture, and (?<name>...) to name a group.

Is my test text sent anywhere?

No. Matching runs in your browser, so you can safely test patterns against real logs or data.