Regex Tester

Test JavaScript regular expressions as you type. Matches are highlighted in your text, each match and capture group is listed, and you can preview replacements. A library of ready patterns includes Indian formats such as PAN, GSTIN, IFSC, Aadhaar, PIN code and mobile numbers.

Quick regex reference

PatternMatches
\d \w \sdigit, word character (letter, digit, _), whitespace
. any character except a new line (tick “s” to include new lines)
[abc] [^abc] [a-z]one of, none of, range
* + ? {3} {2,5}0 or more, 1 or more, optional, exactly 3, 2 to 5
^ $ \bstart, end (of each line with “m”), word boundary
(…) (?:…) (?<name>…)capture group, non-capturing group, named group
a|ba or b
(?=…) (?!…)followed by, not followed by

Flags: g find all matches, i ignore case, m make ^ and $ work on each line, s let . match new lines, u Unicode mode (needed for \p{L} letter classes).

Frequently asked questions

What is the regex for an Indian mobile number?

^[6-9]\d{9}$: ten digits starting with 6, 7, 8 or 9. Add (?:\+91[\s-]?|0)? at the start to allow a +91 or 0 prefix.

What is the PAN card regex?

^[A-Z]{5}[0-9]{4}[A-Z]$: five letters, four digits and one letter, for example ABCDE1234F.