1、匹配数字 \d
Pattern compile = Pattern.compile("\\d"); Matcher matcher = compile.matcher(str);
2、匹配多个 \d+
Pattern compile = Pattern.compile("\\d+");
Matcher matcher = compile.matcher(str);
3、匹配数字开头 ^\d+
Pattern compile = Pattern.compile("^\\d+");
Matcher matcher = compile.matcher(str);