Regex for Indian Mobile Number, PIN Code, PAN and Email
Copy-ready regex patterns for Indian PIN codes, PAN, 10-digit mobile numbers, emails and URLs, with tested examples and how to check them in a regex tester.
The short answer
For common Indian form fields, these regex patterns are a good start: a 6-digit PIN code is ^[1-9]\d{5}$, a PAN is ^[A-Z]{5}[0-9]{4}[A-Z]$, a 10-digit mobile number with an optional +91 or 0 prefix is ^(?:\+91[\s-]?|0)?\d{10}$, and a practical email pattern is [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}. Paste any of them into the Regex Tester with your own sample data to see exactly what matches before you put them in code.
How to test a pattern in the Regex Tester
The tester has three parts:
- Regular expression. Type the pattern between the two slashes. Do not type the slashes yourself.
- Flags. The small box after the closing slash.
gfinds every match,iignores case,mmakes^and$work per line. You can combine them, such asgm. - Test string. Paste sample input. Matches are highlighted, and each one is listed with its position (index) and any captured groups.
If the pattern has a syntax error, the error message appears under the pattern box instead of results. Without the g flag, the tester shows only the first match.
The patterns run in your browser's JavaScript regex engine, so results match what you will get in JavaScript code. Other languages (Python, Java, PHP) use very similar syntax for everything in this guide.
Validation vs searching: the one idea that matters most
The same pattern behaves very differently depending on whether it is anchored.
- Validating a field (is this whole input a PIN code?) needs
^at the start and$at the end. Without them,110001abcwould pass because it contains six digits. - Finding values inside text (pull every email out of a paragraph) needs no anchors, plus the
gflag.
To test a validation pattern against several samples at once, put one sample per line and use the flags gm. Each line that matches is highlighted; lines that fail are not.
Indian PIN code
Pattern: ^[1-9]\d{5}$
A PIN code is six digits. The first digit identifies the postal zone: 1 to 8 are regional zones and 9 is used for the Army Postal Service. No zone uses 0, so the pattern rejects a leading 0.
| Input | Result |
|---|---|
| 110001 | Match |
| 560034 | Match |
| 012345 | No match (starts with 0) |
| 11000 | No match (5 digits) |
| 1100011 | No match (7 digits) |
This checks the format only. It cannot tell you whether a PIN code actually exists; for that you need a lookup against a postal database.
PAN (Permanent Account Number)
Pattern: ^[A-Z]{5}[0-9]{4}[A-Z]$
A PAN has 10 characters: five letters, four digits, one letter. Within the first five letters, the fourth shows the type of holder (for example P for an individual, C for a company, H for a Hindu Undivided Family, F for a firm), and the fifth is the first letter of the holder's name. The last letter is a check character.
| Input | Result |
|---|---|
| ABCPK1234F | Match |
| abcpk1234f | No match (lower case) |
| ABCPK12345 | No match (ends in a digit) |
| ABCP1234F | No match (only 9 characters) |
Stricter version: ^[A-Z]{3}[ABCFGHJLPT][A-Z][0-9]{4}[A-Z]$ restricts the fourth letter to the holder-type codes A, B, C, F, G, H, J, L, P and T. With it, ABCXK1234F no longer matches.
Two practical tips:
- Convert input to upper case before checking, or add the
iflag, because people often type PANs in lower case. - A regex cannot verify the check character or that the PAN belongs to the person. Use it to catch typing mistakes, not as identity verification.
Indian mobile number
Pattern: ^(?:\+91[\s-]?|0)?\d{10}$
This accepts exactly 10 digits, optionally preceded by +91, +91 (with a space), +91- or a single leading 0.
| Input | Result |
|---|---|
| 9876543210 | Match |
| +91 9876543210 | Match |
| +91-9876543210 | Match |
| 09876543210 | Match |
| 98765 43210 | No match (space in the middle) |
| 987654321 | No match (9 digits) |
Many sites also restrict which digit a mobile number may start with. If your business rules require that, change \d{10} to [6-9]\d{9} or whatever range your requirement specifies, and test it against real numbers from your users.
A better user experience is often to strip spaces and dashes first, then validate the cleaned value. That way 98765 43210 and 98765-43210 both pass.
Finding numbers inside text: (?:\+91[\s-]?)?\b\d{10}\b with the g flag. In "Call 9876543210 or +91 9123456780 today; ref 12345678901" it finds the two phone numbers and skips the 11-digit reference, because \b requires a boundary on both sides of the 10 digits.
Email address
Pattern (search): [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
This is the tester's default example. With the g flag, in "Mail ravi.k@example.co.in or info@site.com, not ravi@localhost" it finds ravi.k@example.co.in and info@site.com, and skips ravi@localhost because there is no dot and top-level domain.
For validating a single field, anchor it: ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$.
No simple regex matches every valid email address. Patterns like this one reject some unusual but legal addresses and accept some impossible ones (such as two dots in a row). The only real test is sending a confirmation email.
Website URLs in text
Pattern: https?:\/\/[^\s]+
This grabs anything from http:// or https:// up to the next space. Test it on "See https://lazyblink.com/tools and http://example.org/a?b=1." and you will see the second match includes the full stop at the end. When extracting URLs from sentences, clean trailing punctuation such as ., , and ) afterwards.
Common mistakes
- Forgetting anchors in validation, so extra characters slip through.
- Forgetting
mwhen testing many lines with^and$; without it only the whole text is checked as one string. - Over-strict rules that reject real users, such as banning
+in emails. - Escaping twice. In the tester, type
\d. Inside a string in code (for examplenew RegExp("\\d")) you need to double the backslash. - Pasting HTML into the test string. The tester highlights matches inside the text, so markup like tags may display oddly. Test with plain text samples.
New to the syntax? Read the regex beginner guide first. If you need to clean a list before validating it, the Remove Duplicate Lines tool helps.
Frequently asked questions
What is the regex for an Indian PIN code?
Use ^[1-9]\d{5}$ to validate a 6-digit PIN code that does not start with 0. It checks format only, not whether the PIN code exists.
What is the regex for a PAN number?
Use ^[A-Z]{5}[0-9]{4}[A-Z]$ for five letters, four digits and one letter. Convert input to upper case first, or add the i flag.
How do I validate a 10-digit mobile number with +91?
^(?:\+91[\s-]?|0)?\d{10}$ accepts 10 digits with an optional +91, +91 followed by a space or dash, or a leading 0.
Why does my regex match extra characters?
For validating a whole field, add ^ at the start and $ at the end. Without anchors, the pattern can match part of a longer input.
Put this guide into practice with our free online tool — no signup required.
Open tool