Just use replace
in place of replaceAll
replaceAll
take REGEX as input, not a String, but regex. []
are important parts of regexes using to group expressions.
localStringBuilder.toString().replace("[sender]", callerName);
will work exaclty as you expect, because it takes normal Strings as both parameters.
is the same. Works when is no [] characters in string
– @mbrc 1 min ago
not true, I've tested it:
public static void main(String[] args) {
String s = "asd[something]123";
String replace = s.replace("[something]", "new1");
System.out.println(replace);
}
output: asdnew1123