Split string mutliple characters

Hi i have this string,

private string vals = "Date 1-Score1@Date 2 -Score 2@Date 3-Score 3@Date 4-Score 4@Date 5-Score 5@Date 6-Score6";

i know this will spilt the @, but how do i spilt the - aswell

string[] temp = vals.Split ("@" [0])

also note: the reason why i didn’t just change @ to - is that it’s used for soemthing

Do the split that you propose. That’ll give you your temp string array. Then do a split on each member of the temp array, to give you new arrays with the data split at the minus signs.

Alternatively, and I think what I’d do, is use vals.IndexOf() to locate the position of the @ or - chars, and then use vals.Substring() twice to chop the string into a start string and end string. Then repeat this using the end string and swapping the character to look for.

	string bob = "-";
	
	int i = 0;
	while ((i = vals.IndexOf(bob)) > 0) {
		string temp = vals.Substring(0, i);
		vals = vals.Substring(i+1);
		if (bob.Equals("-")) {
			bob = "@";
		} else {
			bob = "-";
		}
		Debug.Log(temp);
	}