using System.Text.RegularExpressions;
public static void Main()
string regExp_C = @"^C[0-9]*C+\s+A[0-9]{9}A+\s+[0-9]+C";
string regExpC_C = @"^C[0-9]{5,15}C+\s+A[0-9]{9}A+\s+C+[0-9]+C";
string regExp_D_C = @"^C[0-9]{5,15}C+\s+A[0-9]{9}A+\s+[0-9]+D+[0-9]+C";
string regExpC_D_C = @"^C[0-9]{5,15}C+\s+A[0-9]{9}A+\s+C+[0-9]+D+[0-9]+C";
if (Regex.IsMatch(text.ToString(),regExp_C))
else if(Regex.IsMatch(text.ToString(),regExpC_C))
else if(Regex.IsMatch(text.ToString(),regExp_D_C))
else if(Regex.IsMatch(text.ToString(),regExpC_D_C))
Console.WriteLine("Invalid");
Console.WriteLine("Valid");