正则表达式

String input = "ABCD1234BCDE";
        String mode = "BCD";

        Pattern pattern = Pattern.compile(mode);
        int count = 0;
        Matcher matcher = pattern.matcher(input);
        while(matcher.find()) {
            count++;
        }

匹配到两次就会退出while循环

注意不能这么写,这么写永远退不出来

while(pattern.matcher(input).find()) {
            count++;
        }

判断字符串里有没有点,以及用点来进行切分注意写法

if (code.contains(".")) {//不是正则
                String[] nums = code.split("\\.");//是正则
原文地址:https://www.cnblogs.com/juniorMa/p/15744090.html