62,615
社区成员
发帖
与我相关
我的任务
分享
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test {
/**
* 匹配现有的手机号码<br/>
* 号段:130-139, 150-153, 155-159, 188-189
*/
public final static Matcher MOBILE_REGEX_MATCHER = Pattern.compile("(?:1(?:3[0-9]|5[0-35-9]|8[89]))[0-9]{8}").matcher("");
public static void main(String[] args) {
String[] str = {
"13012345677", "13112345678", "13801234567", "13412345679",
"15112345678", "15812345678", "18812345678", "18912345679"
};
for(int i = 0; i < str.length; i++) {
System.out.println(str[i] + " --> " + MOBILE_REGEX_MATCHER.reset(str[i]).matches());
}
}
}