代码如下,一定记着“.”
public static boolean isStartWithNumber(String str) {
Pattern pattern = Pattern.compile("[0-9].*");//一定记住加“.”
Matcher isNum = pattern.matcher(str.charAt(0)+"");
if (!isNum.matches()) {
return false;
}
return true;
}
一定记住正则表达式有点要加上,网上资料好多没有的,调了好久。