final String message =
"Please enter the following code in the password reset screen:\n" +
"\n"+
"{CODE} (((((" + codeStr + ")))))\n" +
"If you didn't ask for this code, or don't know what this e-mail is about, you can safely ignore it."
.replace("{CODE}", codeStr);
This results in
Please enter the following code in the password reset screen: {CODE} (((((5RE2GT4FWH))))) If you didn’t ask for this code, or don’t know what this e-mail is about, you can safely ignore it.
How can such a simple replace not work? I thought that maybe the problem was that the two instances of {CODE} looked alike but were in fact composed of different characters, but I copy-pasted one over the other and it didn’t fix it.
You are invoking the
replace()only on the lastStringobject: ["If you didn't ask for this code, or don't know what this e-mail is about, you can safely ignore it."].Store it [the final
String, before thereplace()] to some temp variable and retry, or use parentheses.