Confirm Indian phone number with extra number +91 or 0 to 10 digits

I use the following reg expression to verify the Indian phone number. I want the option +91 or 0 in front of 10 digits of the phone. How can I do it?

 ^[789]\d{9}$ 
+4
source share
2 answers

You can use ^([0]|\+91)?\d{10} , starting with 0 or +91 and 10 digits after that.

.. but as you must have seen, the number starts at 7.8 or 9

Then you should use ^([0]|\+91)?[789]\d{9}$ , which means that it starts with 7 , 8 or 9 and then follows the numbers 9 .

Some random coincidences;

 +919802422462 08150166859 
+6
source

It should do

 ^(0|\+91)?[789]\d{9}$ 

? optionally matches the previous character or group.

+2
source

Source: https://habr.com/ru/post/1482802/


All Articles