I am poor in Regular Expressions. I googled and got basic understanding of it.
I have below requirement: My command may contain some strings with "$(VAR_NAME)" pattern. I need to find out whether it has such type of strings or not. If so, I have to resolve those(I know what should I do, if such strings are there). But, problem is, how to find whether command has strings with "$(VAR_NAME)" pattern. There might be multiple or zero of such string patterns in my command.
As per my knowledge, I have written below code. If I use, 'pattern1' , in below code, it is matching. But, not with 'pattern'
Can someone help in this?
Thank you in advance.
final String command = "somescript.file $(ABC_PATH1) $(ENV_PATH2) <may be other args too here>";
final String pattern = "\\Q$(\\w+)\\E";
//final String pattern1 = "\\Q$(ABC_PATH1)\\E";
final Pattern pr = Pattern.compile(pattern);
final Matcher match = pr.matcher(command);
if (match.find())
{
System.out.println("Found value: " + match.group(0));
}
else
{
System.out.println("NO MATCH");
}