${} - Regex Expression

java, regex

Solution

try this

    Matcher m = Pattern.compile("\\$\\{(.*?)}").matcher(s);
    while(m.find()) {
        System.out.println(m.group(1));
    }

Problem

I really tried to learn Regex expressions correctly, but, it really blows my mind when I need to build one of them. It`s painful and I lost several hours to build them. So, I need the community help. I`ve an XML String, and I want to build a Regex pattern to identify any occurence of: ``` ${Variable1} ${VARIABLE_TEST} ``` etc. So, anything that starts with `${` and ends with `}`. Could anyone help-me?

Original source