Pattern p = Pattern.compile("^\\+(?:[0-9] ?){6,14}[0-9]$");
//Match the given string with the pattern
Matcher m = p.matcher(numberstr);
//check whether match is found
boolean numberFound = m.matches();
Run Code Online (Sandbox Code Playgroud)
1)如果要验证文本字段,那么他们只能输入您需要输入XML的电话号码
android:phoneNumber="true"
Run Code Online (Sandbox Code Playgroud)
2)或者,如果您想验证电话号码,请使用Linkify类,并且您可以使用它提供的MatchFilter接口来获取密码序列中的已识别电话号码.
| 归档时间: |
|
| 查看次数: |
3091 次 |
| 最近记录: |