I have a String variable that contains ‘*’ in it. But Before using it I have to replace all this character.
I’ve tried replaceAll function but without success:
text = text.replaceAll("*","");
text = text.replaceAll("*",null);
Could someone help me? Thanks!
Why not just use
String#replace()method, that does not take aregexas parameter: –In contrary,
String#replaceAll()takes a regex as first parameter, and since*is a meta-character in regex, so you need to escape it, or use it in a character class. So, your way of doing it would be: –But, you really can use simple replace here.