判断一个string是否以数字开头
public static void main(String[] args) {
Pattern pattern =null;
String content = "30.年前";
if(content.contains(".")){
pattern = Pattern.compile("^(\\d+.{0,1})(.*)");
}else{
pattern = Pattern.compile("^(\\d+)(.*)");
}
Matcher matchers = pattern.matcher(content);
if (matchers.matches()) {//数字开头
//System.out.println(matchers.group(1));// =30
//System.out.println(matchers.group(2));// =年前
}
}