dimanche 19 avril 2015

How do I replace the '|' character in a string in java?

I have a weird problem in one of my programs, I simply want to replace every occurrence of "||" with "OR" in a string, but for some reason it replaces every blank space with "OR", is "|" some sort of escape character or something?


I've been using this statement to do it



ans = ans.replaceAll("||", "OR");


Does anyone know what's going on or how I can fix this?


Aucun commentaire:

Enregistrer un commentaire