Ciao
se quello di cui hai bisogno è poter ottenere tutti i valori compresi fra [] e {}, e memorizzare l'ordine in cui si presentano, le Regular Expressions fanno proprio al caso tuo: utilizzi una regex colla quale catturi tutti i valori compresi fra {} e [] salvando il risultato in un MatchCollection, quindi sfrutti le proprietà di ogni singolo Match nella collection per ottenere l'indice, il valore e il tipo (quandra o graffa) di ciascuno:
Regex regex = new Regex(@"{.*?}|\[.*?]", RegexOptions.Singleline);
MatchCollection matches = regex.Matches(text);
foreach (Match match in matches)
{
match.Value; // Il valore ottenuto (incluse le parentesi)
match.Index; // L'indice in base 0 del match
match.Length; // La lunghezza del match ottenuto
if (match.Value[0] == '{')
{
//Il match è racchiuso fra graffe
}
else
{
//Il match è racchiuso fra quadre
}
}
Luca