2

Unable to split string by multiple characters.

String myString = 'abc$$$xyz';
string[] myArray = myString.Split('$$$');
System.Debug(myArray.Size());

I get result for myArray.Size = 1 and when myArray = 'abc$$$xyz'

Please shed some light

3

String.split() expects a regular expression, not a string.

Use

myString.Split('\\$\\$\\$');

(Thanks to @Mugambo)

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm#apex_System_String_split

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.