Is it possible to do a split() in Unity JS to turn a string to array, where the separator has more than one character, as in the below:
Apple Banana Canapple
Is it possible to do a split() in Unity JS to turn a string to array, where the separator has more than one character, as in the below:
Apple Banana Canapple
The link that Mike provided in that other question shows the different options for String.Split. As you can see there, there's an option to use a string array instead of a char array, so you can provide a string array with one entry:
var test = "1a11abc2b22abc3c33";
var strings = test.Split(["abc"], System.StringSplitOptions.None);
for (s in strings) print (s);
There isn't a default for StringSplitOptions when you use a string array, so you have to provide something, such as None.
Have you tried this:
var arr = str.Split("
"[0]);
Debug.Log(arr[0]);
*Note, I'm pretty sure this will only work if the string actually contains the "` `" characters.