I have a file with below contents:
Test:Line1@line.com
Goal:[[goal]]
Email:[[email]]
Further Text
Below is code to get the file contents into a StringBuffer and get the value into the String output.
Path signature = Paths.get("signature.txt");
StringBuffer sigBuffer = new StringBuffer();
String line = null;
BufferedReader reader = null;
try {
 reader = Files.newBufferedReader(signature);
 while ((line = reader.readLine()) != null) {
   sigBuffer.append(line);
   sigBuffer.append("\n");
 }
 String output = sigBuffer.toString();
} catch...finally...
I want to replace the [[goal]] with Goal A
AND [[email]] with email@mail.com
I tried this:
String regExp = "\\[\\[[a-z_]*\\]\\]";
output.replaceFirst(regExp, "Goal A");
output.replaceFirst(regExp, "email@mail.com");
But my output is still:
Test:Line1@line.com
Goal:[[goal]]
Email:[[email]]
Further Text
 
    