You need to sign in to do that
Don't have an account?
crazyforcer
How to differentiate " and \" in apex string variable?
Hi,
string str = '"abcde\"fgh"'; // "abcde\"fgh"
Apex will treat first and last " and \" are same. But I would like to replace \" with '#DQ#'. That is, I should get "abcde#DQ#fgh".
How can this be achieved? If this is a silly question, please forgive me. :-)
string str = '"abcde\"fgh"'; // "abcde\"fgh"
Apex will treat first and last " and \" are same. But I would like to replace \" with '#DQ#'. That is, I should get "abcde#DQ#fgh".
How can this be achieved? If this is a silly question, please forgive me. :-)
but if you want to pass any special char (wildcard) in string then you can use '\'
like below example
If i want to create a query like below in String
Then
Please let us know if this will help you
Thanks,
Amit Chaudhary
In my case the value to be stored in the variable is "abcde\"fgh" where first " and last " along with \" are the chracters in the string. So,
string str = '"abcde\"fgh"'; // "abcde\"fgh"
So, I should have something like:
str = str.replace('\"', '#DQ#');
But if I use like this, the output string will be #DQ#abcde#DQ#fgh#DQ#. That is, apex will treat normal double quote (") and escaped double quote (\") as same. My requirement is to differentiate them as I need to use a double quoute inside double quote.