Skip to content
JustTools

Regex Tester

Write a regular expression and see it work as you type — every match and group highlighted, each part explained in plain English, with replace, extraction, tests and ready-made patterns for Indian data such as PAN, GSTIN, IFSC and mobile numbers.

Runs in your browser Free · no sign-up

At a glance

  • Tests JavaScript (ECMAScript) regular expressions live as you type, with all six flags: g, i, m, s, u and y.
  • Every match and capture group — numbered and named — is highlighted and listed with its position.
  • A plain-English explanation of each part of the pattern: classes, quantifiers, groups, lookarounds and backreferences.
  • Replace with $1, $<name> and $&, list matches with a template (handy for pulling data into CSV), and unit tests of strings that should and shouldn’t match.
  • Code for JavaScript, Python, PHP, Java, C# and Go, with named groups, flags and replacements rewritten for each language.
  • Patterns run in a separate worker and are stopped after 1.5 seconds, so a runaway (catastrophic backtracking) pattern can’t freeze the page. 24 ready-made patterns, including Indian PAN, GSTIN, IFSC, PIN code, mobile and vehicle numbers.

Step by step

How to test a regular expression

  1. 1

    Write the pattern

    Type it between the slashes and switch on the flags you need — g to find every match.

  2. 2

    Add your text

    Paste the text to search; matches are highlighted and listed with their groups.

  3. 3

    Read the explanation

    Check what each part of the pattern does, and fix anything unexpected.

  4. 4

    Replace, test or copy code

    Use the tabs to preview a replacement, extract matches, run tests or copy code for your language.

Features

Everything you need, nothing you don’t

Live highlighting

Matches light up in your text as you type, alternating colours so neighbours stand apart.

Explained in English

Each token of the pattern is described, indented by group, so you can read any regex.

Replace and extract

Preview replacements and turn matches into lists or CSV lines in one step.

Unit tests

Keep strings that must and mustn’t match beside the pattern and see which fail.

Safe to experiment

A slow pattern is stopped automatically instead of hanging your browser tab.

Share a link

The pattern, flags and text travel in the link itself — nothing is stored on a server.

Regex quick reference

PatternMeaning
.Any character except a line break (any at all with the s flag)
\d \w \sA digit, a word character, whitespace (capitals for the opposite)
[abc] [^abc] [a-z]One of a, b or c · anything else · a range
* + ? {2,5}0 or more · 1 or more · optional · 2 to 5 times (add ? for as few as possible)
(…) (?<name>…) (?:…)Capture group · named group · group without capturing
^ $ \bStart · end (of a line with the m flag) · word boundary
(?=…) (?!…) (?<=…) (?<!…)Followed by · not followed by · preceded by · not preceded by
\1 \k<name>The same text a group matched

Regex for Indian data

WhatPattern
Mobile number(?:\+91[\s-]?|0)?[6-9]\d{4}[\s-]?\d{5}
PAN[A-Z]{5}\d{4}[A-Z]
GSTIN\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]
IFSC[A-Z]{4}0[A-Z0-9]{6}
PIN code[1-9]\d{2}\s?\d{3}

FAQ

Frequently asked questions

Which regex flavour does this use?

JavaScript (ECMAScript), the engine built into your browser — the same one Node.js uses. The Code tab rewrites the pattern for Python, PHP, Java, C# and Go, and warns when something (such as lookbehind in Go) isn’t supported there.

Why does my regex find only one match?

Without the g (global) flag, a regular expression stops at the first match. Switch on g to find them all.

What is catastrophic backtracking?

Some patterns, usually with nested quantifiers like (a+)+ or (.*)*, can take exponentially long on text that almost matches. This tester runs patterns separately and stops them after 1.5 seconds, then tells you to make the pattern more specific.

How do I validate a whole value, not just part of it?

Anchor the pattern with ^ at the start and $ at the end, e.g. ^[A-Z]{5}\d{4}[A-Z]$ for a PAN. In the Tests tab, “The whole line must match” does this for you.

Is my text sent anywhere?

No. Everything runs in your browser. A shared link carries the pattern, flags and up to 2,000 characters of text inside the link itself.

Keep going

Browse every tool

Last updated Report a problem or suggest a feature