Splitting a string in C#

Use the Regex.Matches method instead:

string[] result =
  Regex.Matches(str, @"\[.*?\]").Cast<Match>().Select(m => m.Value).ToArray();

Leave a Comment