Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. namespace _3s
  5. {
  6. class izp_3Snow
  7. {
  8. static void Main()
  9. {
  10. string pattern1 = @"([^a-zA-Z0-9_\s]+)";
  11. string pattern2 = @"([\d_]+)";
  12. string pattern3 = @"([^a-zA-Z0-9_\s]+)([\d_]+)([a-zA-Z]+)([\d_]+)([^a-zA-Z0-9_\s]+)";
  13. //string patternCore = @"([a-zA-Z]+)";
  14.  
  15. bool isValid = false;
  16. string mid = "";
  17.  
  18. string l1 = Console.ReadLine();
  19. string l2 = Console.ReadLine();
  20. string l3 = Console.ReadLine();
  21. string l4 = Console.ReadLine();
  22. string l5 = Console.ReadLine();
  23.  
  24. isValid = Regex.IsMatch(l1, pattern1);
  25. if (isValid == true)
  26. {
  27. isValid = Regex.IsMatch(l2, pattern2);
  28. if (isValid == true)
  29. {
  30. isValid = Regex.IsMatch(l3, pattern3);
  31. if (isValid == true)
  32. {
  33. MatchCollection midM = Regex.Matches(l3, pattern3);
  34. foreach (Match item in midM)
  35. {
  36. mid = item.Groups[3].ToString();
  37. }
  38.  
  39. isValid = Regex.IsMatch(l4, pattern2);
  40. if (isValid == true)
  41. {
  42. isValid = Regex.IsMatch(l5, pattern1);
  43. if (isValid == true)
  44. {
  45. Console.WriteLine("Valid");
  46. Console.WriteLine(mid.Length);
  47. }
  48. }
  49. }
  50. }
  51. }
  52. else if(isValid == false)
  53. {
  54. Console.WriteLine("Invalid");
  55. }
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement