using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; public class Test { public static void Main() { var text = "0:1:a:b"; var results = Regex.Match(text, @"^(?:([01ab])(?::\b|$))+$")? .Groups[1].Captures.Cast().Select(c => c.Value); Console.WriteLine(string.Join(", ", results)); } }