Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace � in a string

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?

like image 854
Thizzer Avatar asked Sep 28 '09 19:09

Thizzer


People also ask

How do you replace a specific character in a 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.

What is replaceAll \\ s in Java?

Java String replaceAll() The replaceAll() method replaces each substring that matches the regex of the string with the specified text.

How can I replace two values in a string in Java?

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.


1 Answers

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", "\""); 
like image 126
Gunslinger47 Avatar answered Sep 25 '22 17:09

Gunslinger47