fork(9) download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. var r = new Regex("^\\d(\\d|(?<!-)-)*\\d$|^\\d$");
  9. Console.WriteLine(r.IsMatch("1-2-3"));
  10. Console.WriteLine(r.IsMatch("1-222-3333"));
  11. Console.WriteLine(r.IsMatch("123"));
  12. Console.WriteLine(r.IsMatch("1--23"));
  13. Console.WriteLine(r.IsMatch("1-2-3-"));
  14. Console.WriteLine(r.IsMatch("1"));
  15. Console.WriteLine(r.IsMatch("-11-2-3-"));
  16. }
  17. }
Success #stdin #stdout 0.06s 37280KB
stdin
Standard input is empty
stdout
True
True
True
False
False
True
False