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);