- Home /
convert string to list of lists
I have a long string that represents animation frames. Each frame is delimited by $
within each frame is a information in the form of object:value delimited by * for example:
s= object:value*object:value$object:value*object;value
I'm trying to convert this string into new List.< >();
Is there an easy way to do this?
my current method is to split the frames first by $ then split the frameinfo by * Then use a for loop to put the results into the generic lists...
function parseStringToLists(s:String){
animation=new List.<List.<String> >();
var framedata=Regex.Split(s,"\\*");
for(var i=0;i<framedata.length;i++){
var framestrings=Regex.Split(framedata[i],"\\$");
var framestringsList=new List.<String>();
for(var k=0;k<framestrings.length;k++){
framestringsList.Add(framestrings[k]);
}
animations[i].Add(framestringsList);
}
}
The Error I get is
The best overload for the method 'System.Collections.Generic.List..Add(String)' is not compatible with the argument list '(System.Collections.Generic.List.)'.
Answer by Bunny83 · Jun 04, 2013 at 10:53 PM
This line:
animations[i].Add(framestringsList);
should be
animations.Add(framestringsList);
Your answer
Follow this Question
Related Questions
Splitting String only on a "space". Using my method --- FIXED 2 Answers
How to convert a string to int array in Unity C# 1 Answer
Change part of a string [Solved] 3 Answers
Strings, Arrays and Split in js 1 Answer
Splitting String Into Array 2 Answers