How to use the regex tester
- Type a pattern between the slashes and pick flags.
- Paste your test string. Matches are highlighted instantly.
- Check the list below for the position and capture groups of each match.
About this tool
Type a pattern and a test string and see every match highlighted as you type, with the position and capture groups of each match listed below. Toggle the global, ignore case, multiline, dotAll and unicode flags. The engine is your browser JavaScript, so results match what your front-end or Node.js code will do.
Pattern cheat sheet
| Pattern | Meaning |
|---|---|
| \d \w \s | A digit, a word character, a whitespace character |
| . | Any character except a line break |
| ^ $ | Start and end of the text (or of a line with the m flag) |
| * + ? | Zero or more, one or more, zero or one |
| {3} {2,5} | Exactly 3, or between 2 and 5 |
| [a-z] [^0-9] | A character in a set, or not in a set |
| (abc) (?:abc) | A capturing group, and a non-capturing group |
| a|b | a or b |
| (?=x) (?<=x) | Lookahead and lookbehind |
Patterns for Indian formats
These check the format only. They cannot tell you whether a number or ID really exists.
| Field | Pattern |
|---|---|
| Mobile number | ^[6-9]\d{9}$ |
| PIN code | ^[1-9][0-9]{5}$ |
| PAN | ^[A-Z]{5}[0-9]{4}[A-Z]$ |
| GSTIN | ^\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]$ |
Flags
- g (global) finds all matches instead of stopping at the first.
- i ignores upper and lower case.
- m makes ^ and $ match at every line, not just the whole text.
- s lets . match line breaks as well.
- u turns on full Unicode matching.
When a pattern hangs the page
Nested repetition such as (a+)+ can force the engine to try an enormous number of combinations on certain text, which freezes the tab. This is called catastrophic backtracking. Simplify the pattern, avoid repeating a group that can itself match the same characters, and test with short strings first.
Differences between regex engines
This tester uses the JavaScript engine in your browser. It supports named groups like (?<year>\d{4}) and lookbehind in current browsers, but not every feature of Python, PCRE, Java or .NET, such as possessive quantifiers or inline flags. Test in the language you will deploy on before you rely on a complex pattern.
Frequently asked questions
Which regex flavour is used?
JavaScript (ECMAScript), the engine in your browser. Python, PCRE, and Java differ slightly in lookbehind and named group syntax.
Why is my page freezing?
Nested quantifiers like (a+)+ can cause catastrophic backtracking. Simplify the pattern or shorten the test text.
Is my text uploaded?
No. Everything runs in your browser. Nothing is uploaded.
Why does my regex match only once?
Turn on the global (g) flag. Without it, only the first match is returned.
How do I match a literal dot or bracket?
Escape it with a backslash, for example \. for a dot or \[ for a bracket.