Я предлагаю регулярное выражение
\A(?:\s*\d{10},)*\s*\d{10}\s*\Z
Пояснение:
\A # start of the string
(?: # match the following zero or more times:
\s* # optional whitespace, including newlines
\d{10}, # 10 digits, followed by a comma
)* # end of repeated group
\s* # match optional whitespace
\d{10} # match 10 digits (this time no comma)
\s* # optional whitespace
\Z # end of string
В C # это будет выглядеть как
validInput = Regex.IsMatch(subjectString, @"\A(?:\s*\d{10},)*\s*\d{10}\s*\Z");
Обратите внимание, что вам нужно использовать дословную строку (@"..."
) или удвоить все обратные слеши в регулярном выражении.