I have a string that contains a character � I haven't been able to replace it correctly.
String.replace("�", "");
doesn't work, does anyone know how to remove/replace the � in the string?
Using 'str.replace() , we can replace a specific character. If we want to remove that specific character, replace that character with an empty string. The str. replace() method will replace all occurrences of the specific character mentioned.
Java String replaceAll() The replaceAll() method replaces each substring that matches the regex of the string with the specified text.
Replace Multiple Characters in a String Using replaceAll() in Java. replaceAll() is used when we want to replace all the specified characters' occurrences. We can use regular expressions to specify the character that we want to be replaced.
That's the Unicode Replacement Character, \uFFFD. (info)
Something like this should work:
String strImport = "For some reason my �double quotes� were lost."; strImport = strImport.replaceAll("\uFFFD", "\"");
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