7

I want to remove all strange special characters from a string in Java. Those strange special characters are appearing in form of ?(Question mark) in MS Word.The image of sample string is given below.

enter image description here

psms
  • 752
  • 2
  • 15
  • 34

2 Answers2

2

You can use

String newString = my_string.replaceAll("\\p{C}", "");

more information about Java Unicode Regular expression Java Unicode Regular expression here

Emdadul Sawon
  • 5,122
  • 2
  • 42
  • 46
1

This will work:

String string = yourString.replaceAll("[^\\x00-\\x7F]", "");
Santosh Jadi
  • 1,401
  • 6
  • 28
  • 52