Regex Patterns Library

Find a tested regular expression for the format you need, copy it for JavaScript, Python, Java, C# or PHP, and try it on your own values right on the page. Indian formats sit next to the usual ones: mobile numbers with +91, PAN, GSTIN, IFSC, PIN codes, Aadhaar format, vehicle registration numbers, UPI IDs and amounts with Indian commas. Every pattern comes with examples it accepts and rejects.

Category

Indian mobile number

Ten digits starting with 6, 7, 8 or 9, with an optional +91, 91 or 0 in front and an optional space or dash in the middle.

JavaScript/^(?:\+91[\-\s]?|91|0)?[6-9]\d{4}[\-\s]?\d{5}$/
Pythonre.compile(r'^(?:\+91[\-\s]?|91|0)?[6-9]\d{4}[\-\s]?\d{5}$')
Java / C# string"^(?:\\+91[\\-\\s]?|91|0)?[6-9]\\d{4}[\\-\\s]?\\d{5}$"
PHP'/^(?:\+91[\-\s]?|91|0)?[6-9]\d{4}[\-\s]?\d{5}$/'
  • 9876543210matches
  • +91 98765 43210matches
  • +91-9876543210matches
  • 09876543210matches
  • 919876543210matches
  • 5876543210does not match
  • 98765 4321does not match
  • +1 9876543210does not match
  • 98765432100does not match

Testing runs in your browser. What you type never leaves this device.

Features

  • 40+ patterns in seven groups, with Indian formats first

  • Each pattern tested against examples that should and should not match

  • Copy as JavaScript, Python, Java/C# string or PHP

  • Try your own values: pass or fail per line, or highlighted matches

  • Plain notes on what each pattern does not check

  • Runs in your browser

Where these patterns help

Form validation

Check a mobile number, PIN code or PAN as the customer types, before the form is sent.

Cleaning spreadsheets

Find rows with a badly formatted GSTIN or IFSC in exported data.

Extracting data

Pull OTPs, hashtags, @mentions or UTM tags out of text.

Using a pattern well

Format is not validity

A regex checks shape: ten characters in the PAN layout, or fifteen in the GSTIN layout. It cannot tell whether the number was issued. GSTIN and Aadhaar end in a check character that needs a small piece of code to verify, and card numbers need the Luhn check. The descriptions say where this applies.

Anchors and flags

  • Patterns starting with ^ and ending with $ check a whole value. Use them for form fields.
  • Patterns without anchors find matches inside longer text; they carry the g flag.
  • Patterns using \p{...} need the u flag in JavaScript and the third-party regex module in Python.

Build your own

Adjust a pattern and test it with full match details in the regex tester. To pull phone numbers or emails out of a document, try extract phone numbers or extract emails.

Regex Patterns Library - FAQ