I want to get mykey stored in custom setting and escape the reserved characteres.
originalstring = 'abc123def'pqr456\eryt' ;
// escaping the reserved charatcters
String mykeyAfterEscapingReservedCharacters = 'abc123def\'pqr456\\eryt' ;
If I escape the reserved characters directly in Apex code, I get the output correctly. However if store the string mykeyAfterEscapingReservedCharacters = abc123def\'pqr456\eryt in the custom setting and access it in apex code I get an error because the reserved characters are not escaped.
customsetting cs = new customsetting.getInstance();
string mystringfromcustomsetting = cs.mykeyAfterEscapingReservedCharacters;
systeom.debug(mystringfromcustomsetting );
// output = abc123def\'pqr456\\eryt