String replaceAll doesn't work!!!
Hello everybody, I have a problem, I am using a Jtextpane for a chat app... the problem is that I need to replace the :) :( :/ etc expressions to <img src='image.gif'> for example...
I tried using replaceAll method:
message.replaceall(":)", "<img src='image.gif'>");
It didn't work at all... it just cleared the string...
message.replaceall("://)", "<img src='image.gif'>");
Didn't work either
message.replaceall("//://)", "<img src='image.gif'>");
That didn't clear the string, but it didn't replace anything...
How can I do it???
Re: String replaceAll doesn't work!!!
Are you using the return value or discarding it?
Also, see BB Code List - Java Programming Forum
db
Re: String replaceAll doesn't work!!!
Apparently replaceAll doesn't replace the chars in the same string but it generates a new string instead...
I had it fixed by doing this:
message = message.replaceall(":)", "<img src='image.gif'>");
Re: String replaceAll doesn't work!!!
And that is because Strings are immutable.
They cannot be changed.