replace all occurrences of '\\' with '\\\\' in value, replace all occurrences of '"' with '\\"' in the previous result,
return value . replace ( '\\' , '\\\\' ) . replace ( '"' , '\\"' ) . replace ( "'" , "\\'" )