I am trying to find environment variables in input and replace them with values.
The pattern of env variable is ${\\\\.}
Pattern myPatte
Use groups once it is matched ${env1}
will be your first group and then you use regex to replace what is in each group.
Pattern p = Pattern.compile("(${\\.})");
Matcher m = p.matcher(line);
while (m.find())
for (int j = 0; j <= m.groupCount(); j++)
//here you do replacement - check on the net how to do it;)