How can I replace a String $1 in Java? I tried this, but this doesn't replace it:
System.out.println(someHTMLCodeAsString.replaceAll("$1", "REPLACED"));
The $ is being interpreted as regex instead of as a character (it means 'end of line'). Try System.out.println(someHTMLCodeAsString.replaceAll("\\$1", "REPLACED"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With