using System.Text.RegularExpressions;
public static void Main()
var reg = new Regex(@"^A(?<adults>\d+)(\+C(?<children>\d+))?(\+I(?<infants>\d+))?$", RegexOptions.Compiled);
var tests = new String[] { "A3", "A3+C4", "A22+C4+I9" };
for (var i = 0; i < tests.Length; i++)
Console.WriteLine($"Tested string: {tested}");
var matches = reg.Match(tested);
Console.WriteLine($"Adults: {matches.Groups["adults"]}");
Console.WriteLine($"Children: {matches.Groups["children"]}");
Console.WriteLine($"Infants: {matches.Groups["infants"]}\n");