String replaceAll() question!
Hello,
i'm using the following to replace two characters from my input string
String str;//some input string
str = str.replaceAll("a","bc");
str = str.replaceAll("x","yz");
Is there a way to do this in single command (using String'sreplace() or
replaceAll()... or something else)?
Kind regards!
[495 byte] By [
igor_ba] at [2007-11-27 5:05:21]

just write that:
String str; //some input string
str = str.replaceAll("a", "bc").replaceAll("x", "yz");
It is so simple.
Good Luck.
Ahmad Elsafty
> tr = str.replaceAll("a", "bc").replaceAll("x","yz");
If the OP needs something more sophisticated than this then he should look at
http://elliotth.blogspot.com/2004/07/java-implementation-of-rubys-gsub.html