fork download
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. class Program
  5. {
  6. static void Main(string[] args)
  7. {
  8. string regex = "^[^|]*\\|[^|]*\\|[^|]*\\|\\|";
  9.  
  10. Console.WriteLine("abc|123|234||673");
  11. Match myMatch = Regex.Match("abc|123|234||673", regex);
  12. Console.WriteLine(myMatch.Success);
  13.  
  14. Console.WriteLine("abc|def||123|456");
  15. myMatch = Regex.Match("abc|def||123|456", regex);
  16. Console.WriteLine(myMatch.Success);
  17.  
  18. Console.WriteLine("abc|123|234|673||ab");
  19. myMatch = Regex.Match("abc|123|234|673||ab", regex);
  20. Console.WriteLine(myMatch.Success);
  21.  
  22. Console.WriteLine("abc|123|234|673||ab||");
  23. myMatch = Regex.Match("abc|123|234|673||ab||", regex);
  24. Console.WriteLine(myMatch.Success);
  25. }
  26. }
Success #stdin #stdout 0.07s 34048KB
stdin
Standard input is empty
stdout
abc|123|234||673
True
abc|def||123|456
False
abc|123|234|673||ab
False
abc|123|234|673||ab||
False