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.
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
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.
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
| 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
Frequently asked questions
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
JSON Formatter & Validator
Format, validate, minify and repair JSON online. Get the exact line and column of every error, a collapsible tree view and sorted keys — private, in-browser.
Word Counter
Free online word counter: count words, characters, sentences and paragraphs as you type, with reading time, keyword density, readability and limits.
Case Converter
Change text case online: UPPERCASE, lowercase, Title Case, Sentence case, and camelCase, snake_case or kebab-case for code. Smart rules, instant, free.
Markdown to HTML Converter
Convert Markdown to clean HTML online: GitHub tables, task lists and highlighted code, as a snippet or full page, minified or not. Batch files, no upload.
XML to JSON Converter
Convert XML to JSON and JSON to XML online. Keeps attributes, arrays and leading zeros intact, shows exact error lines and never uploads your data.
DNS Lookup
Free DNS lookup: check A, AAAA, CNAME, MX, NS, TXT, SOA and CAA records of any domain, see SPF and DMARC, and do reverse DNS for an IP address.
Last updated Report a problem or suggest a feature