Regular Expression Validation For Indian Phone Number and Mobile number

前端 未结 12 752
后悔当初
后悔当初 2020-12-01 09:26

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



        
相关标签:
12条回答
  • 2020-12-01 10:01

    For Indian Mobile Numbers

    Regular Expression to validate 11 or 12 (starting with 0 or 91) digit number

    String regx = "(0/91)?[7-9][0-9]{9}";
    
    String mobileNumber = "09756432848";
    
    check 
    
    if(mobileNumber.matches(regx)){
       "VALID MOBILE NUMBER"
    }else{
       "INVALID MOBILE NUMBER"
    }
    

    You can check for 10 digit mobile number by removing "(0/91)?" from the regular expression i.e. regx

    0 讨论(0)
  • 2020-12-01 10:07

    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/

    0 讨论(0)
  • 2020-12-01 10:11
    var phonereg = /^(\+\d{1,3}[- ]?)?\d{10}$/;
    
    0 讨论(0)
  • 2020-12-01 10:14

    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
    0 讨论(0)
  • 2020-12-01 10:15

    All mobile numbers in India start with 9, 8, 7 or 6. Now, there is a chance that you are not bothering about the prefixes (+91 or 0). If this is your scenario, then you can take the help from the website regextester.com or you can use r'^(+91[-\s]?)?[0]?(91)?[789]\d{9}$'

    And if you want to validate the Phone number with prefixes(+91 or 0) then use : r'^[9876]\d{9}$'.

    0 讨论(0)
  • You can use regular expression like this.

    /^[(]+\ ++\d{2}[)]+[^0]+\d{9}/

    0 讨论(0)
提交回复
热议问题