public static List <string> Scan(string input, string pattern) { return(MyRegex.Matches(input, pattern) .Cast <Match>() .Select(m => (m.Groups.Count == 2) ? m.Groups[1].Value : m.Value) .ToList()); }