0
I have a string with a content and I need to make a replaceAll, but the text to be replaced contains a "$" dollar sign and this causes the error Illegal group reference
.
Example:
String texto="teste {{texto}} teste";
String trocar="_$_";
texto=texto.replaceAll("\\{\\{texto\\}\\}", trocar);
Note: This "swap" string comes from a database, so I cannot add the . The example is only illustrative.
Tried to use the scape? ""?
– Roknauta
This "swap" string comes from a database. The example is only illustrative. (editing the pargunta)
– NilsonUehara
You can force the escape of
$
for\$
, edited my answer to exemplify– brow-joe