I need to format a string removing the control characters before creating it as an xml. The texts are both in English and French. For eg in words like d?une, I wanted to remove "?" from the text. I tried \p{Cntrl}, [\u0000-\u001f], /[^a-zA-ZÀ-ÿ]/ none of them worked. Could anyone suggest a solution thanks in advance
Asked
Active
Viewed 46 times
1 Answers
0
This will search and replace all non ASCII letters:
String resultString = subjectString.replaceAll("[^\\x00-\\x7F]", "");
Courtesy of FailedDev -> Replace non ASCII character from string.

Cardinal System
- 2,749
- 3
- 21
- 42
-
Thanks for the suggestion but this will not work in texts like "Isolant de polystyr�ne extrud� rig" where I want to strip of control characters like this.. Do you have any other suggestion ? – DJ4186 Dec 01 '17 at 16:03
-
1