You need to sign in to do that
Don't have an account?

Add Double quotes to string
Hello,
I have an Apex class where I am parsing the selected values from a multiselect.
How can I add double quotes to each element?
I have big, small, medium.
I need "big","small","medium"
Any suggestion would be appreciated.
Cheers,
P
I have an Apex class where I am parsing the selected values from a multiselect.
How can I add double quotes to each element?
I have big, small, medium.
I need "big","small","medium"
Any suggestion would be appreciated.
Cheers,
P
Please try below code, let me know if you face any issues. Thanks.
All Answers
Please try below code, let me know if you face any issues. Thanks.
Please use the below code to get the required string.
String d = 'big, small, medium';
String[] size = d.split(',');
String First = '"'+size[0]+'",';
String Second = '"'+size[1]+'",';
String Third = '"'+size[2]+'"';
String newString = First+Second+Third;
System.debug(newString);
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Sachin Arora
www.sachinsf.com
Cheers,
P