Contact
India Mobile Number Regex
Indian mobile numbers have ten digits, and the first digit is currently 6, 7, 8 or 9. People often add the +91 country code or a domestic trunk 0 in front, and this pattern accepts both as well as a single space or dash after +91. That makes it suitable for OTP sign-up screens, delivery apps and lead forms aimed at Indian users. Spaces inside the ten-digit number are not accepted, so normalise input first. The limit is that it cannot tell whether a number is active or which operator currently serves it.
Pattern (JavaScript)
/^(?:\+91[ -]?|0)?[6-9][0-9]{9}$/Starts at the start of the line/string, then (the text "+91", then one of the characters -, optionally (zero or one time) OR the character "0"), optionally (zero or one time), then one of the characters 6-9, then a digit, exactly 9 times, then the end of the line/string.
Limit: Checks the format only; it cannot tell whether the number is active.
Examples
Matches
- ✓ 9876543210
- ✓ +91 9876543210
- ✓ 09123456789
Does not match
- ✗ 5876543210
- ✗ 987654321
- ✗ +92 9876543210
Try it
0 matches (JavaScript engine)
9876543210
+91 9876543210
09123456789
5876543210
987654321
+92 9876543210Code in 8 languages
Converted automatically from the JavaScript pattern; language-specific notes are shown where the syntax or support differs.
JavaScript
const re = /^(?:\+91[ -]?|0)?[6-9][0-9]{9}$/g;
const text = "9876543210";
const matches = [...text.matchAll(re)].map((m) => m[0]);
console.log(matches);Python
import re
pattern = re.compile(r'^(?:\+91[ -]?|0)?[6-9][0-9]{9}$')
text = '9876543210'
matches = [m.group(0) for m in pattern.finditer(text)]
print(matches)PHP
<?php
$pattern = '/^(?:\+91[ -]?|0)?[6-9][0-9]{9}$/';
$text = '9876543210';
preg_match_all($pattern, $text, $matches);
print_r($matches[0]);Java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
Pattern pattern = Pattern.compile("^(?:\\+91[ -]?|0)?[6-9][0-9]{9}$");
String text = "9876543210";
Matcher matcher = pattern.matcher(text);
while (matcher.find()) {
System.out.println(matcher.group());
}
}
}Go
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`^(?:\+91[ -]?|0)?[6-9][0-9]{9}$`)
text := "9876543210"
fmt.Println(re.FindAllString(text, -1))
}C#
using System;
using System.Text.RegularExpressions;
var pattern = new Regex(@"^(?:\+91[ -]?|0)?[6-9][0-9]{9}$");
var text = "9876543210";
foreach (Match m in pattern.Matches(text))
{
Console.WriteLine(m.Value);
}Rust
// Cargo.toml: regex = "1"
use regex::Regex;
fn main() {
let re = Regex::new(r"^(?:\+91[ -]?|0)?[6-9][0-9]{9}$").unwrap();
let text = "9876543210";
for m in re.find_iter(text) {
println!("{}", m.as_str());
}
}- Add regex = "1" under [dependencies] in Cargo.toml.
Ruby
pattern = /^(?:\+91[ -]?|0)?[6-9][0-9]{9}$/
text = '9876543210'
matches = text.to_enum(:scan, pattern).map { Regexp.last_match[0] }
p matchesFrequently asked questions
- Why must the number start with 6, 7, 8 or 9?
- Indian mobile number series are allocated in ranges starting with those digits, while landlines use other leading digits. Requiring 6 to 9 separates mobiles from most landline entries.
- How do I accept 98765 43210 with a space?
- Either strip spaces before testing or change the pattern to [6-9][0-9]{4} ?[0-9]{5} so a single space in the middle is allowed.
- Should I store the number with +91?
- Storing the E.164 form +91 followed by ten digits is the safest choice, because SMS providers expect it. Normalise the number after the pattern matches.