Remove ASCII Question Mark

2019-07-24 12:31发布

问题:

I have the following String passed from another application.

2�4�9�

(2�4�9�)

I would like to remove question mark ascii characters from the above string.

How could I do this?

回答1:

According to this Unicode code table, � (or \ufffd) is the character �.

You can remove this unicode character from your string with :

str = str.replaceAll("�", "");

But you should really try to understand why they are there.



回答2:

string.replaceAll("\u0000.*","").replaceAll("[^a-zA-Z0-9 ]", "");

will remove the empty spaces & punctuation marks in the string variable.



标签: java ascii