Reg-Expression to validate Indian Mobile Numbers (+91
, 91
, 0
) starting with 9
, 8
, 7
, 6
and should be in the below formats:
8994455555
7994455555
6994455555
9994455555
99944 55555
99944-55555
999 445 5555
999-445-5555
+91
+919994455555
+91 9994455555
+91-9994455555
+91999 445 5555
+91-999-445-5555
+91 999-445-5555
+91 999 445 5555
+9199944 55555
+91-99944-55555
+91 99944-55555
+91 99944 55555
91
919994455555
91 9994455555
91-9994455555
91999 445 5555
91-999-445-5555
91 999-445-5555
91 999 445 5555
9199944 55555
91-99944-55555
91 99944-55555
91 99944 55555
0
09994455555
0 9994455555
0-9994455555
0999 445 5555
0-999-445-5555
0 999-445-5555
0 999 445 5555
099944 55555
0-99944-55555
0 99944-55555
0 99944 55555
Reg-Expression that supports all the above formats is
r'^((\+)?(91[\-\s]?))|(0[\-\s]?)?((([6-9]{1}\d{2})-?\s*?(\d{3})-?\s*?(\d{4}))|(([6-9]{1}\d{4})-?\s*?(\d{5})))$'
invalid formats:
54623987
56489 56489
563 589 6456
+91 563 898 5647
91 562563
91 5645555555
91 66555855575
0 55556 45654
((\+)?(91[\-\s]?))
: (\+)?
begin with a +
sign (Not Compulsory) followed by (91[\-\s]?)
gives 91
, 91
and 91-
(Not Compulsory).|
.(0[\-\s]?)?
begin with a 0
(Not Compulsory).((([6-9]{1}\d{2})-?\s*?(\d{3})-?\s*?(\d{4}))
Consider ([6-9]{1}\d{2})-?\s*?
, Indian Mobile Numbers begin with either 6
, 7
, 8
or 9
, followed by any 2-digits from 0-9
(\d{2}
). Next it will be no-space, (-
) or space (Not Compulsory) - followed by next 3-digits from 0-9
(\d{3}
). Which is again followed by no-space, (-
) or space (Not Compulsory). Finally, 4-digits from 0-9
(\d{3}
) --> Format 563-898-5647
, 563 898 5647
or 5638985647
|
.(([6-9]{1}\d{4})-?\s*?(\d{5}))
Consider ([6-9]{1}\d{4})-?\s*?
, Indian Mobile Numbers, followed by any 4-digits from 0-9
(\d{4}
). Next it will be no-space, (-
) or space (Not Compulsory) - followed by next 3-digits from 0-9
(\d{5}
). --> Format 56389-85647
, 56389 85647
or 5638985647
.try the following regex:
^(\+91[\-\s]?)?[0]?(91)?[789]\d{9}$