Regex Patterns for Indian Phone Numbers, PIN, PAN, GSTIN and IFSC
Almost every Indian web form asks for a mobile number, PIN code or PAN, and validating them with a regular expression catches typing mistakes before the data reaches your database. But copy-pasted patterns are often wrong or too strict.
This guide gives clear patterns for common Indian formats, explains each part, and shows how to test them. Remember that a pattern checks the shape of a value — not whether the number, PAN or account actually exists.
How to read and test these patterns
Each pattern below starts with ^ and ends with $, which means the whole value must match — not just part of it. \d means a digit, [A-Z] an uppercase letter, and {n} means "exactly n times".
Paste a pattern into Regex Tester with some sample values, one per line, and turn on the m (multiline) flag so ^ and $ apply to each line. Always test valid and invalid examples.
Mobile numbers
Indian mobile numbers have 10 digits and start with 6, 7, 8 or 9: ^[6-9]\d{9}$.
To also accept an optional +91 or 0 prefix with an optional space or dash: ^(?:\+91[\-\s]?|0)?[6-9]\d{9}$. In practice it is often easier to remove spaces, dashes and the prefix first, then validate the 10 digits.
PIN codes
An Indian PIN code has 6 digits and does not start with 0: ^[1-9]\d{5}$. Some forms let people type a space after the third digit (380 015); remove spaces before validating.
PAN
A PAN has 10 characters: five letters, four digits and one letter, such as ABCDE1234F. Pattern: ^[A-Z]{5}\d{4}[A-Z]$. Convert the input to uppercase before checking, because people often type it in lowercase.
The fourth letter indicates the holder type (P for an individual, C for a company and so on). You can check it with ^[A-Z]{3}[ABCFGHLJPT][A-Z]\d{4}[A-Z]$ if you need to, but most forms accept the general pattern.
GSTIN
A GSTIN has 15 characters: a 2-digit state code, the 10-character PAN, an entity number (1–9 or A–Z), the letter Z by default, and a check character. Pattern: ^\d{2}[A-Z]{5}\d{4}[A-Z][1-9A-Z]Z[0-9A-Z]$.
The last character is a checksum that a regex cannot verify. For important data, calculate the checksum in code or verify the GSTIN with the official GST portal.
IFSC and vehicle numbers
An IFSC code has 11 characters: 4 letters for the bank, a 0, and 6 letters or digits for the branch: ^[A-Z]{4}0[A-Z0-9]{6}$.
Vehicle registration numbers vary between states and series, so strict patterns reject real numbers. A practical pattern for common formats such as GJ01AB1234 is ^[A-Z]{2}\d{1,2}[A-Z]{0,3}\d{4}$, after removing spaces and dashes.
Validation advice
Normalise first: trim spaces, remove separators and convert to uppercase where it makes sense. Show a helpful message that explains the expected format instead of just "invalid". And never rely only on client-side validation — check again on the server.
Frequently asked questions
Does a matching PAN or GSTIN mean it is real?
No. A regex only checks the format. Verify real identity or tax numbers through official sources or APIs.
Why does my pattern match part of a longer number?
Add ^ at the start and $ at the end so the whole value must match.
Should I accept landline numbers?
Landlines include an STD code and vary in length, so a single strict pattern is hard. Ask for a mobile number, or accept 10–11 digits after removing the leading 0.
Will these patterns work in Python or Java?
Yes — they use common syntax. In Java string literals, double the backslashes (\\d).