Developer Tools
Regex Tester
Regex Tester is part of Toolspire and is ready as soon as this page loads. 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.
On this page
What you can do here
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.
The sequence
How to test a regular expression
- 1
Write the pattern
Type it between the slashes and switch on the flags you need — g to find every match.
- 2
Add your text
Paste the text to search; matches are highlighted and listed with their groups.
- 3
Read the explanation
Check what each part of the pattern does, and fix anything unexpected.
- 4
Replace, test or copy code
Use the tabs to preview a replacement, extract matches, run tests or copy code for your language.
Worth knowing
- Regex Tester on Toolspire: 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.
Regex quick reference
| Pattern | Meaning |
|---|---|
| . | Any character except a line break (any at all with the s flag) |
| \d \w \s | A 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 |
| ^ $ \b | Start · 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
| What | Pattern |
|---|---|
| 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
Questions about Regex Tester
Where does Regex Tester run?
Which regex flavour does this use?
Why does my regex find only one match?
What is catastrophic backtracking?
How do I validate a whole value, not just part of it?
Is my text sent anywhere?
Keep going
Related tools
Last updated Report a problem or suggest a feature