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

0

1 Answer 1

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.