Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Text.RegularExpressions;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ValidUsernames
  9. {
  10. class ValidUsernames
  11. {
  12.  
  13. static void Main(string[] args)
  14. {
  15. string pattern = @"([A-Za-z]+)([\|\\<])(.*)([\|\\<])([A-Za-z]+)";
  16. string input = Console.ReadLine();
  17.  
  18. Match myMatch = Regex.Match(input, pattern);
  19. string start = myMatch.Groups[1].Value;
  20. string end = myMatch.Groups[5].Value;
  21.  
  22. string input2 = Console.ReadLine();
  23. string pattern2 = $@"{start}(.*?){end}";
  24.  
  25.  
  26. StringBuilder builder = new StringBuilder();
  27.  
  28. MatchCollection results = Regex.Matches(input2, pattern2);
  29. bool isEmpty = false;
  30.  
  31. foreach (Match m in results)
  32. {
  33. builder.Append(m.Groups[1].Value);
  34. }
  35. if (builder.Length != 0)
  36. {
  37. Console.WriteLine(builder);
  38. }
  39. else
  40. {
  41. Console.WriteLine("Empty result");
  42. }
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement