string s = new String(myArr);
string[] parts = s.Split(new string[] {"12"}, StringSplitOptions.None);
You can then convert the results to char arrays with
var list = new List<char[]>();
foreach (string part in parts) {
list.Add(part.ToCharArray());
}
EDIT: As you need a universal approach, here are two generic solutions.
If the length of the sub-arrays is always the same then you could do it like this:
public List<T[]> GetSubArrays<T>(T[] array)
{
const int LengthOfSpearator = 2, LengthOfSubArray = 2;
const int LengthOfPattern = LengthOfSpearator + LengthOfSubArray;
var list = new List<T[]>();
for (int i = 0; i <= array.Length - LengthOfSubArray; i += LengthOfPattern) {
T[] subarray = new T[LengthOfSubArray];
Array.Copy(array, i, subarray, 0, LengthOfSubArray);
list.Add(subarray);
}
return list;
}
If the length of the sub-arrays is variable, then the algorithm becomes more complicated. We also have to constrain the generic parameter to be IEquatable in order to be able to make the comparison.
public List<T[]> GetSubArrays<T>(T[] array, T[] separator)
where T : IEquatable<T>
{
int maxSepIndex = array.Length - separator.Length;
var list = new List<T[]>();
for (int i = 0; i <= array.Length; ) {
// Get index of next separator or array.Length if none is found
int sepIndex;
for (sepIndex = i; sepIndex <= maxSepIndex; sepIndex++) {
int k;
for (k = 0; k < separator.Length; k++) {
if (!array[sepIndex + k].Equals(separator[k])) {
break;
}
}
if (k == separator.Length) { // Separator found at sepIndex
break;
}
}
if (sepIndex > maxSepIndex) { // No separator found, subarray goes until end.
sepIndex = array.Length;
}
int lenSubarray = sepIndex - i;
T[] subarray = new T[lenSubarray];
Array.Copy(array, i, subarray, 0, lenSubarray);
list.Add(subarray);
i = sepIndex + separator.Length;
}
return list;
}