I have the following string in which the  special character is coming in hidden. I want to remove only the  from this string ~IQBAL~KARACHI¦~~~~~~~~~~~.
Here is a before and after image to show what I mean:

I've tried this code:
responseMessageUTF.replaceAll("\\P{InBasic_Latin}", "");
but this is also replacing the ¦ character. Is there any way to remove only the  character and not the ¦ character?
I have a simple one liner code, it removes for most of the non-UTF-8 characters. I tested for your character as well i.e. Â.
String myString = "~KARACHI¦~~~~~~";
String result = myString.replaceAll("[^\\x00-\\x7F]","");
System.out.println(result);
You can find complete code here. You may test that as well here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With