I have a string array and I want to split by another array(by each item from second array).
string[] array1 = { "item1", "item2", "item3", "item4", "item5" ,"item6" };
string[] array2 = { "item2", "item5" };
results in string[][] or List<string[]>
results[0] = { "item1" }
results[1] = { "item2", "item3", "item4" }
results[2] = { "item5", "item6" }
Also item which split should added before next array. eg. item2 splited results[0] and results[1] and and used in front of result[1].
Hints: It might be something like using IndexOf() or Insert() in for loop function
I have tried this with string. but I don't know how to proceed with array.
string str = "item1,item2,item3,item4,item5,item6";
string[] array = str.Split(new string[] { "item2","item5" }, StringSplitOptions.None);
I tried find this question in google but so far nothing found. Only thing I found how split in chuncks(meaning number of items in each array) but not by another item(multiple items Especially).
item5comes beforeitem2? Must it be split first onitems2anyway?