Take the 2-minute tour ×

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.

share|improve this question
\"\\u00A2\" what are you trying to do here? why the quotes? –  Cruncher Nov 13 '13 at 16:40
so it considers it as a char –  Rani Nov 13 '13 at 16:43
add comment

1 Answer

up vote 3 down vote accepted
string = string.replaceAll("¢|\\$", "");


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

$ is a special character in regular expressions, so you have to escape it, unless it's in a character class.

share|improve this answer
string = string.replaceAll("[¢ $]", ""); worked for me. –  Rani Nov 13 '13 at 16:47
@Rani Glad I could help! –  Steve P. Nov 13 '13 at 16:48
Yeah, that's right. You don't have to escape special characters inside of a set –  Cruncher Nov 13 '13 at 16:49
also string.replaceAll("[\\u00A2" $]", "") works.. Thanks guys. such a stupid mistake I made =/ –  Rani Nov 13 '13 at 16:51
@Rani Be careful if you use your solution, you have a space in your character class. –  Steve P. Nov 13 '13 at 16:52
show 1 more comment

Your Answer


