Advertisement
MilenaPetkanova

Regexmon

Nov 1st, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. using System;
  2. using System.Text.RegularExpressions;
  3.  
  4. class Regexmon
  5. {
  6. static void Main()
  7. {
  8. string input = Console.ReadLine();
  9.  
  10. string didiPattern = @"[^a-zA-Z-]+";
  11. string bojoPattern = @"[a-zA-Z]+-[a-zA-Z]+";
  12.  
  13. while (true)
  14. {
  15. var didiMatch = Regex.Match(input, didiPattern);
  16. if (didiMatch.Success)
  17. {
  18. string didimon = didiMatch.Value.ToString();
  19. Console.WriteLine(didimon);
  20. }
  21. else
  22. {
  23. return;
  24. }
  25.  
  26. input = input.Remove(0, didiMatch.Index + didiMatch.Length);
  27.  
  28. var bojoMatch = Regex.Match(input, bojoPattern);
  29. if (bojoMatch.Success)
  30. {
  31. string bojomon = bojoMatch.Value.ToString();
  32. Console.WriteLine(bojomon);
  33. }
  34. else
  35. {
  36. return;
  37. }
  38.  
  39. input = input.Remove(0, bojoMatch.Index + bojoMatch.Length);
  40.  
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement