Android Phone Number Check isPhoneNumber(final String phone)

Here you can find the source of isPhoneNumber(final String phone)

Description

is Phone Number

Declaration

public static boolean isPhoneNumber(final String phone) 

Method Source Code

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    private static final String telNumRegex = "((\\d{11})|^((\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})|(\\d{4}|\\d{3})-(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1})|(\\d{7,8})-(\\d{4}|\\d{3}|\\d{2}|\\d{1}))$)";

    public static boolean isPhoneNumber(final String phone) {
        Pattern pattern = Pattern.compile(telNumRegex);
        Matcher macther = pattern.matcher(phone.trim());
        return macther.find() ? true : false;
    }/* w  w  w . jav  a  2s  .  c o m*/
}

Related

  1. isPhoneNumber(String inputStr)
  2. isPhone(String phoneNumber)
  3. isTelNumAvailable(String telNum)
  4. isMobile(String mobiles)
  5. isMobileNO(String phoneNum)
  6. isLegalPhoneNumber(String phoneNumber)