fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. public class Test
  5. {
  6. public static void Main()
  7. {
  8. // Validar número 00n-nnnnnn
  9. string valor = "001-000001";
  10. Regex re = new Regex(@"^00[1-9]-[0-9]{6}$");
  11.  
  12. if (re.IsMatch(valor)) {
  13. Console.WriteLine("Válido");
  14. }
  15. else
  16. {
  17. Console.WriteLine("Error");
  18. }
  19. }
  20. }
Success #stdin #stdout 0.1s 24720KB
stdin
Standard input is empty
stdout
Válido