Reputation: 328
I have to replace a string whit special character like this: XY_Universit�-WWWWW-ZZZZZ
in another one like: XY_Universita-WWWWW-ZZZZZ
.
I tryed solutions like stringToReplace.replaceAll(".*Universit.*", "Universita");
but it replace all the string with the word ''Universita" and it isn't what i want.
Thanks in advance
F
Upvotes: 0
Views: 335
Reputation: 26077
public static void main(String[] args) throws IOException {
String exp = "XY_Universit�-WWWWW-ZZZZZ";
exp = exp.replaceAll("Universit[^a]", "Universita");
System.out.println(exp);
}
Output
XY_Universita-WWWWW-ZZZZZ
Upvotes: 1