New blogMaking an AI Agent You Can Trust With Money

★ India · regex

Regex for Indian Mobile Number

Indian mobile numbers are 10 digits and start with 6, 7, 8 or 9. This accepts the common ways people type them: with +91, 91 or a leading 0, and an optional space after the fifth digit.

  • Runs in your browser
  • No signup

Try the indian mobile number pattern

Read it in plain English (best-effort)

  • ^start of a line
  • (?:start a group (not captured)
  • +91the text '+91'
  • [ -]one character from: space, '-'
  • ?the previous is optional
  • |or
  • 91the text '91'
  • [ -]one character from: space, '-'
  • ?the previous is optional
  • |or
  • 0the character '0'
  • )end of group
  • ?the previous is optional
  • [6-9]one character from: 6–9
  • \da digit (0–9)
  • {4}exactly 4 of the previous
  • [ -]one character from: space, '-'
  • ?the previous is optional
  • \da digit (0–9)
  • {5}exactly 5 of the previous
  • $end of a line

One sample per line works well with the m flag on anchored patterns.

Waiting for a pattern
01

The pattern, piece by piece

/^(?:\+91[ -]?|91[ -]?|0)?[6-9]\d{4}[ -]?\d{5}$/
Pattern explanation
PartWhat it does
(?:\+91[ -]?|91[ -]?|0)?optional prefix: +91, 91 or a trunk 0
[6-9]mobile numbers start with 6, 7, 8 or 9
\d{4}[ -]?\d{5}nine more digits, optionally split 5 + 5
02

What it accepts and rejects

Every sample below is checked automatically in JavaScript and Python. The tester above is preloaded with all of them, one per line.

Should match
Should match
9876543210✓
+91 9876543210✓
+919876543210✓
09876543210✓
98765 43210✓
+91-6123456789✓
Should not match
Should not match
5876543210✗
987654321✗
98765432101✗
+92 9876543210✗
+91 98765-4321✗
0091 9876543210✗
03

Copy it into your code

RE2-safeNo lookarounds or backreferences, so the same pattern works in Go's RE2 engine and in Rust's regex crate.

const indianMobileRe = /^(?:\+91[ -]?|91[ -]?|0)?[6-9]\d{4}[ -]?\d{5}$/;

export function isValidIndianMobile(value) {
  return indianMobileRe.test(value.trim());
}
04

When not to use regex for this

Format checks don't prove ownership. Send an OTP to verify the number, and store it normalised as E.164 (+919876543210) using libphonenumber.

05

Questions engineers actually ask

Do Indian mobile numbers still start only with 6–9?
Yes, mobile numbering in India uses the 6–9 range for the first digit of the 10-digit number.
Does it accept landline numbers?
No. Landlines use STD codes and different lengths; use libphonenumber if you need both.
What is catastrophic backtracking?
Some patterns, usually nested quantifiers like (a+)+, make a backtracking engine try an exponential number of paths on input that almost matches. The tester stops any run after 300ms, so a bad pattern can't freeze your tab. In production, that same pattern can take down a server (a ReDoS attack).
06

More india patterns

07

More from the workbench

Fine print

Tools: on the house.
Engineer: by the hour.

The regex was free. Code that doesn't need one is the upgrade: typed schemas, validated once at the edge, trusted everywhere after.

I'm Himanshu, an AI and full-stack engineer. I build MVPs, AI agents and the growth plumbing around them for early-stage startups.