fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Text.RegularExpressions;
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var inputs = new string[] { "1, 2, 3", "1, myword, 3", "1, MyWord, 3" };
  10. var pat = @"^\s*((?:\d+|myword)(\s*,\s*(?:\d+|myword))*)?\s*$";
  11. foreach (var s in inputs)
  12. Console.WriteLine("{0} matched: {1}", s, Regex.IsMatch(s, pat, RegexOptions.IgnoreCase));
  13. }
  14.  
  15. }
  16.  
  17.  
Success #stdin #stdout 0.1s 24368KB
stdin
Standard input is empty
stdout
1, 2, 3 matched: True
1, myword, 3 matched: True
1, MyWord, 3 matched: True