1

I have a string with "Dollars" and "Cents" symbol in it. I want to remove them. I tried

string.replaceAll("[\"\\u00A2\" $]", "")

but its not working. What is the correct way to do it.

4

1 回答 1

3
string = string.replaceAll("¢|\\$", "");

或者

string = string.replaceAll("\\u00A2|\\$", "");

$是正则表达式中的特殊字符,因此您必须对其进行转义,除非它在字符类中。

于 2013-11-13T16:40:21.413 回答