Results 1 to 4 of 4
- 06-25-2012, 09:32 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 37
- Rep Power
- 0
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???
- 06-25-2012, 09:49 AM #2
Re: String replaceAll doesn't work!!!
Are you using the return value or discarding it?
Also, see BB Code List - Java Programming Forum
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 06-25-2012, 09:56 AM #3
Member
- Join Date
- Apr 2012
- Posts
- 37
- Rep Power
- 0
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'>");
- 06-25-2012, 11:29 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Similar Threads
-
Why doesn't this work?
By mailman in forum Java AppletsReplies: 5Last Post: 01-10-2012, 01:01 PM -
string replaceall occurences with strings inside arrays
By DeCoolJB in forum New To JavaReplies: 1Last Post: 10-08-2011, 05:41 AM -
Jar doesn't work
By mad72584 in forum New To JavaReplies: 35Last Post: 08-07-2011, 05:22 PM -
String.replaceAll(str, str) is leading to infinite loop. Help?
By TheNadz in forum New To JavaReplies: 2Last Post: 04-25-2011, 04:13 PM -
Regular Expressions and String.replaceAll()
By meta1203 in forum New To JavaReplies: 1Last Post: 11-24-2010, 11:41 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks