如何在字符串中寻找${demo}

public static void main(String[] args) {

        String formula = "XXXX${date}V${demo}VVV";
        String reg = "\\$\\{[^}]+\\}";
        Pattern p = Pattern.compile(reg);
        Matcher matcher = p.matcher(formula);
        while (matcher.find()) {
            System.out.println(matcher.group());
        }
    }

你可能感兴趣的:(Date,String)