1

I'm trying to replace [br] with <br /> in a Java String.

someText.replaceAll("\\[br\\]","<br />");

This doesn't work at all. I tried removing the backslashes but I got the same result.

2 Answers 2

12

Java strings are immutable. You need to assign the return value back to someText:

someText = someText.replaceAll("...");
Sign up to request clarification or add additional context in comments.

Comments

4

Strings are not mutable. are you handling the result of the replaceAll() method calll?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.