java 正则表达式匹配${xxx}

public static void main(String[] a) {
        // 待处理字符串
        String wpp = "jdbc:mysql://${wpp1}:${wpp2}/${wpp3}?&useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull";
        //\u0024\u007B\u0028\u002E\u002A\u003F\u0029}
        // 匹配方式
        Pattern p = Pattern.compile("\\$\\{(.*?)}");
        // 匹配】
        Matcher matcher = p.matcher(wpp);
        // 处理匹配到的值
        while (matcher.find()) {
            System.out.println("woo: " + matcher.group());
        }
    }
posted @ 2020-01-14 14:19  果果虫  阅读(5906)  评论(1编辑  收藏  举报