Removing certain characters from strings and converting to a list

Hello!

I am sending query data from Unity3D to an external API.
The API is taking my query, generating a result and sending it back.

However when it sends back certain values, it sends them back like this:

[“c7385f31-2c3e-42ae-aae2-57c5ea66088f”, “e6f8f4db-76c4-43a9-b5d3-5d3be606cabd”, “22a55fa7-bf1f-46d9-9c1e-67336c4f55c4”]

That is a list of id codes sent from the API to me. However it is all one continuous string.

How would I go about converting this into a list?

I figure what I need to do is remove firstly the ['s and then seperate each one from each other. I’m not too sure how to go about it and have searched the internet for a solution but haven’t found one.

(I am using C# btw, and heard that lists were better than arrays for this particular thing. Please do correct me if I’m wrong!)

Thanks!!

Just use String.Split, in combination with Substring to strip the outer characters. Then it doesn’t matter if the lengths are the same or not. You don’t need a List; an array is fine, which is what Split returns.

string input = "[\"c7385f31-2c3e-42ae-aae2-57c5ea66088f\", \"e6f8f4db-76c4-43a9-b5d3-5d3be606cabd\", \"22a55fa7-bf1f-46d9-9c1e-67336c4f55c4\"]";
string[] splitter = {"\", \""};
string[] idCodes = input.Substring(2, input.Length-4).Split(splitter, System.StringSplitOptions.None);

foreach (var id in idCodes) {
	Debug.Log (id);
}

So, you receive “c7385f31-2c3e-42ae-aae2-57c5ea66088fe6f8f4db-76c4-43a9-b5d3-5d3be606cabd22a55fa7-bf1f-46d9-9c1e-67336c4f55c4” and you want to split it up in three and store each parts in a list am I right ?

I guess there isn’t a character of separation then, but each part seems to have the same number of chars (I didn’t count). You should use SubString and add each result to a List< string >