1

I'm trying to define a string with the following value

string s = 'Something\Something';

but I got Illegal character sequence '\S' in string literal.

I tried escaping the backlash with another backlash but I ended up with a string that has two backlashes ('Something\\Something') . What am I doing wrong?

2

You need to use \\ instead \

string s = 'Something\\Something';

system.debug(s);

Output

19:13:22:003 USER_DEBUG [3]|DEBUG|Something\Something

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.