Reputation: 23
i would like to remove a character from java string using hex code:
i am trying following code but seems to not be correct as the character isn't replaced: ÿ
String str ="test ÿ";
str.replaceAll("\\x{9F}","")
is there any thing wrong with the syntax of the hex code? Thanks.
Upvotes: 1
Views: 9042
Reputation: 492
To mach ÿ you need \u00ff instead, as Jon mentioned.
String replaced = str.replace("\u00ff", "");
in your case.
Upvotes: 1
Reputation: 123
Could you please try this:
public class AsciiHexCode {
public static void main(String[] args) {
String str = "test ÿ";
String result = str.replaceAll("[^\\x00-\\x7F]", "");
System.out.println("result : "+ result);
}
}
Upvotes: 1