Regular Expression Validation For Indian Phone Num

2019-01-11 04:23发布

I want to validate Indian phone numbers as well as mobile numbers. The format of the phone number and mobile number is as follows:

For land Line number

03595-259506
03592 245902
03598245785

For mobile number

9775876662
0 9754845789
0-9778545896
+91 9456211568
91 9857842356
919578965389

I would like the regular expression in one regex. I have tried the following regex but it is not working properly.

{^\+?[0-9-]+$}

8条回答
做个烂人
2楼-- · 2019-01-11 04:55

Use the following regex

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

This will support the following formats:

  1. 8880344456
  2. +918880344456
  3. +91 8880344456
  4. +91-8880344456
  5. 08880344456
  6. 918880344456
查看更多
做个烂人
3楼-- · 2019-01-11 04:56

All Landline Numbers and Mobile Number

^[\d]{2,4}[- ]?[\d]{3}[- ]?[\d]{3,5}|([0])?(\+\d{1,2}[- ]?)?[789]{1}\d{9}$

查看更多
登录 后发表回答