mardi 31 mars 2015

Splitting a string into multiple Arrays

For my program, the input from the user will be something like this:



{1,2,3} {1,2} {4,5,6}


There can be multiple { } with any number of ... numbers inside.


I already made a 2 dimensional array with an array for each sequence of numbers: {}


I am having troubling splitting them into their respective arrays so it will be something like this:



Array[0] = ["1","2","3"]
Array[1] = ["1","2"]
Array[2] = ["4","5","6"]


How would i split it like that? i dont know if i can split this string into n number of strings since the number of sequences depends on user.


Aucun commentaire:

Enregistrer un commentaire