How many times has this happened to you?
Youโve built a flawless React component, set up a beautiful CI/CD pipeline, and structured your database perfectly. But then, you hit a simple user onboarding form and spend the next 20 minutes Googling: "Valid regex for Indian GSTIN format" or "Aadhaar card regex javascript".
Sometimes StackOverflow gives you a pattern from 2013, and sometimes ChatGPT hallucinates a format that rejects valid inputs.
I got tired of searching for the same validation codes for every new project. So, this weekend, I built The Indian Regex & Validation Vault.
It is a completely free, minimalist, zero-bloat directory of 100+ Indian-specific regular expressions and validation rules. No sign-ups, no paywallsโjust search, copy, and paste.
Here are 5 essential patterns from the vault you can use right now:
1. Indian PAN Card Validation
The Permanent Account Number (PAN) is a 10-character alphanumeric identifier. The first 5 characters are uppercase alphabets, the next 4 are numbers, and the last is an alphabet.
const panRegex = /^[A-Z]{5}[0-9]{4}[A-Z]{1}$/;
console.log(panRegex.test("ABCDE1234F")); // true
2. Aadhaar Card Validation (With or Without Spaces)
The Aadhaar number is a 12-digit unique identity number. It never starts with a 0 or 1.
// Accepts: 123456789012 or 1234 5678 9012
const aadhaarRegex = /^[2-9]{1}[0-9]{3}\s?[0-9]{4}\s?[0-9]{4}$/;
3. GSTIN (Goods and Services Tax Identification Number)
This is a 15-digit alphanumeric code. The first two digits are the state code, followed by the PAN, one digit for entity number, the letter 'Z' by default, and a checksum character.
const gstinRegex = /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/;
4. Indian UPI ID
Validates standard UPI virtual payment addresses (e.g., username@oksbi or number@ybl).
const upiRegex = /^[a-zA-Z0-9.\-_]{2,256}@[a-zA-Z]{2,64}$/;
5. Indian Vehicle Registration (Number Plate)
Validates formats like MH 12 AB 1234 or DL1A1234.
const vehicleRegex = /^[A-Z]{2}[ -]?[0-9]{1,2}(?:[ -]?[A-Z])?(?:[ -]?[A-Z]*)?[ -]?[0-9]{4}$/;
๐ Get the rest of the 100+ Patterns
If you need validations for Voter ID, Indian Passports, IFSC Codes, Landline numbers with STD codes, or even state-specific Pincodes, I have compiled them all in one place.
I've also added detailed explanations for how each regex works under the hood so you aren't just blindly copying code.
๐ Bookmark the vault here: Aaptics.in - The Indian Regex Vault
(Bonus: There is also a second directory on the site explaining unknown developer system files and extensions like .npmrc or .safetensors!)
Let me know in the comments if I missed any specific Indian document format, and I'll add it to the vault today! Happy coding! ๐จโ๐ป๐ฎ๐ณ
Top comments (0)