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
  • 851
  • 3
  • 18
  • 35

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,730
  • 3
  • 45
  • 48
1

This will work:

String string = yourString.replaceAll("[^\\x00-\\x7F]", "");
Santosh Jadi
  • 1,479
  • 6
  • 29
  • 55