Reputation: 229
I have following xml string, In that I need to replace "dddomain1" with "dddomain"
I used the code below, but not working
xmlString.replaceAll("dddomain1","dddomain");
Upvotes: 1
Views: 91
Reputation: 21
Since String
is immutable, replaceAll()
returns a new String
instead
String newXMLString = xmlString.replaceAll("xpsystems114", "xpsystems");
System.out.println(newXMLString);
Upvotes: 0
Reputation: 326
Strings are immutable. Any operation on returns a new String. Like @Maroun said, assign the returning reference to a String variable.
Upvotes: 2
Reputation: 44834
You do not need
to use the replaceAll
method as this is for regexp.
try
xmlString = xmlString.replace("xpsystems114","xpsystems");
Upvotes: 5