I want a regular expression that will extract _A_, 12345, Non_Literal_Left, and Non_Literal_Right from the following string:
... ${_A_}, ${12345}, '${Literal}' $yada yada'$[]' '${Non_Literal_Left} ${Non_Literal_Right}'
The closest I have been able to get is everything less the single quote restriction for literals:
Matcher matcher = Pattern.compile("\\$\\{(\\w+)\\}").matcher(s);
while (matcher.find()) {
result.add(matcher.group(1));
}
Which results in everything I want plus Literal, which I do not want to match.
Thanks in advance…
That was a joy.
Something tells me a RegEx expression would have been a little cleaner.
And tests, of course.