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-]+$}
This depends a lot on what you want the regex for: if you're importing from a rather dirty database, you might want a liberal expression that just weeds out the completely wrong ones. This one would be enough for the following case:
The phone number:
( ) . - space digit
.(Side Note: According to ITU, phone numbers are limited to max of 15 digits (See Phone Numbering Plan). A max=25 in above Regex accommodates the special characters.)
Visual Explaination
This works really fine:
Matches:
Does NOT match:
For both mobile & fixed numbers:
(?:\s+|)((0|(?:(\+|)91))(?:\s|-)*(?:(?:\d(?:\s|-)*\d{9})|(?:\d{2}(?:\s|-)*\d{8})|(?:\d{3}(?:\s|-)*\d{7}))|\d{10})(?:\s+|)
Explaination:
I've tested it on following text
You Can Use Regex Like This:
For land Line Number
you can use this
\d{5}([- ]*)\d{6}
NEW for all ;)
this site is useful for me, and maby for you .;)http://gskinner.com/RegExr/