Regular Expression Validation For Indian Phone Number and Mobile number

前端 未结 12 772
后悔当初
后悔当初 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

提交回复
热议问题