public static void main(String[] a) { // 待处理字符串 String wpp = "jdbc:mysql://${wpp1}:${wpp2}/${wpp3}?&useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&zeroDateTimeBehavior=convertToNull"; //u0024u007Bu0028u002Eu002Au003Fu0029} // 匹配方式 Pattern p = Pattern.compile("\$\{(.*?)}"); // 匹配】 Matcher matcher = p.matcher(wpp); // 处理匹配到的值 while (matcher.find()) { System.out.println("woo: " + matcher.group()); } }