@Test public void test10(){ String str="a中A3"; String reg="[a-zA-Z]"; Pattern compile = Pattern.compile(reg); Matcher matcher = compile.matcher(str); if(matcher.matches()){ System.out.println("是全字母"); } if (matcher.find()){ System.out.println("有字母"); }
match():是全匹配正则,
find():是部分匹配