fork(1) download
  1. using System;
  2. using System.IO;
  3. using System.Text.RegularExpressions;
  4.  
  5. public class Test
  6. {
  7. public static void Main()
  8. {
  9. var ptrn = @"[^\x20-\x21\x23-\x25\x28-\x2E\x30-\x3B\x3F-\x7E\xA0-\xFF]";
  10. var ptrn2 = @"^[\x20-\x21\x23-\x25\x28-\x2E\x30-\x3B\x3F-\x7E\xA0-\xFF]{0,40}$";
  11. var str = " some text here ";
  12. if (str.Length > 40 || Regex.IsMatch(str, ptrn))
  13. Console.WriteLine("1 - The line is too long or contains invalid char(s)!");
  14. str = "1234567890 1234567890 1234567890 1234567890 1";
  15. if (str.Length > 40 || Regex.IsMatch(str, ptrn))
  16. Console.WriteLine("2 - The line is too long or contains invalid char(s)!");
  17. str = "1234567890 1234567890 1234567890 1234567890";
  18. if (str.Length > 40 || Regex.IsMatch(str, ptrn))
  19. Console.WriteLine("3 - The line is too long or contains invalid char(s)!");
  20.  
  21. str = " some text here ";
  22. if (Regex.IsMatch(str, ptrn2))
  23. Console.WriteLine("2.1 - The line is too long or contains invalid char(s)!");
  24. str = "1234567890 1234567890 1234567890 1234567890 1";
  25. if (Regex.IsMatch(str, ptrn2))
  26. Console.WriteLine("2.2 - The line is too long or contains invalid char(s)!");
  27. str = "1234567890 1234567890 1234567890 1234567890";
  28. if ( Regex.IsMatch(str, ptrn2))
  29. Console.WriteLine("2.3 - The line is too long or contains invalid char(s)!");
  30. }
  31. }
Success #stdin #stdout 0.11s 24368KB
stdin
Standard input is empty
stdout
1 - The line is too long or contains invalid char(s)!
2 - The line is too long or contains invalid char(s)!
3 - The line is too long or contains invalid char(s)!