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()); } }
原文:https://www.cnblogs.com/guoguochong/p/12191761.html