Advertisement
sivancheva

Regexmon

Oct 3rd, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 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 _03_Regexmon
  9. {
  10. class Regexmon
  11. {
  12. static void Main(string[] args)
  13. {
  14.  
  15. //var pattern = new Regex(@"(?<Didimon>[^a-zA-Z-]+)*(?<Bojomon>[a-zA-Z]+-[a-zA-Z]+)*");
  16. var input = Console.ReadLine();
  17. var patternDidimon = new Regex(@"[^a-zA-Z-]+");
  18. var patternBojomon = new Regex(@"[a-zA-Z]+-[a-zA-Z]+");
  19.  
  20. while (true)
  21. {
  22. var matchDidimon = patternDidimon.Match(input);
  23.  
  24. if (matchDidimon.Success)
  25. {
  26. Console.WriteLine(matchDidimon.Value.ToString());
  27. }
  28. else
  29. {
  30. return;
  31. }
  32.  
  33. int firstSymbolDidimon = matchDidimon.Index;
  34.  
  35. input = input.Substring(firstSymbolDidimon + matchDidimon.Length);
  36.  
  37. var matchBojomon = patternBojomon.Match(input);
  38.  
  39. if (matchBojomon.Success)
  40. {
  41. Console.WriteLine(matchBojomon.Value.ToString());
  42. }
  43. else
  44. {
  45. return;
  46. }
  47. int firstSymbolBojomon = matchBojomon.Index;
  48. input = input.Substring(firstSymbolBojomon + matchBojomon.Length);
  49.  
  50. }
  51.  
  52.  
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement