Q:

Android parse quote in string

This should be a really simple question, but i got confused and something isn't working right.    
I want to parse the input string to replace " with [5178] and ' with [5179] which works well, i get the string like i want it to, but when i go the other way, i want to parse [5178] to " and [5179] to ', i get something strange.      
Here is my code:     
    text = text.replaceAll("[5178]","\"");
    text = text.replaceAll("[5179]","\'");

That part doesn't work, and this part does: 
    text = text.replaceAll("\"","[5178]");
    text = text.replaceAll("\'","[5179]"); 

When i input text let's say: Single quote ' and double quote " i get: Single quote [5179] and double quote [5178] , but when i go other way aroung i get Single quote ["""'] and double quote [""""].    
I don't know what is going on, any ideas? 

A:

replaceAll use a regular expression as its first argument. [ and ] are used to delimit a character class in regex so need to be escaped
text = text.replaceAll("\\[5178\\]","\"");

Alternatively you could use
text = text.replaceAll(Pattern.quote("[5178]"), "\"");

