Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular Expression Validation For Indian Phone Number and Mobile number

Tags:

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-]+$} 
like image 278
Iswar Avatar asked Aug 21 '13 07:08

Iswar


People also ask

How can I check if a phone number is valid in India?

Mobile Number validation criteria: The first digit should contain number between 7 to 9. The rest 9 digit can contain any number between 0 to 9. The mobile number can have 11 digits also by including 0 at the starting. The mobile number can be of 12 digits also by including 91 at the starting.

How do you write regex in a phone number?

Regular expression to allow numbers like +111 123 456 789: ^(\\+\\d{1,3}( )?)?(\\d{3}[ ]?){2}\\d{3}$


2 Answers

For land Line Number

03595-259506 03592 245902 03598245785 

you can use this

\d{5}([- ]*)\d{6} 

NEW for all ;)

OLD: ((\+*)(0*|(0 )*|(0-)*|(91 )*)(\d{12}+|\d{10}+))|\d{5}([- ]*)\d{6} NEW: ((\+*)((0[ -]*)*|((91 )*))((\d{12})+|(\d{10})+))|\d{5}([- ]*)\d{6}  9775876662 0 9754845789 0-9778545896 +91 9456211568 91 9857842356 919578965389  03595-259506 03592 245902 03598245785 

this site is useful for me, and maby for you .;)http://gskinner.com/RegExr/

like image 144
M.R Avatar answered Oct 04 '22 20:10

M.R


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
like image 29
Minkesh Jain Avatar answered Oct 04 '22 20:10

Minkesh Jain