正则表达式中 find()和match()区别

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/shuimofengyang/article/details/84848200
@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():是部分匹配

详细可参考:https://www.cnblogs.com/huhongy/p/7541875.html

猜你喜欢

转载自blog.csdn.net/shuimofengyang/article/details/84848200