Faizan Ansari
Faizan Ansari

Reputation: 117

Regular Expression for Indian Mobile No

I want to search for Indian mobile numbers in a file. My regex is working fine for:

+91-9762897662
+919762654329
09762897652

but not for

9762809283

My regex so far:

(\\+\\d{12}|\\d{11}|\\+91-\\d{10,12}|\\+\\d{2}-\\d{3}-\\d{7})

Upvotes: 1

Views: 162

Answers (1)

Bohemian
Bohemian

Reputation: 425198

I think you are over-complicating things. Try this:

((\\+91-?)|0)?\d{10} 

This regex is saying "optional prefix of +91 (with optional -) or 0, followed by 10 digits

Upvotes: 4

Related Questions