Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- namespace _03.RegexMon
- {
- class RegexMon
- {
- static void Main()
- {
- string text = Console.ReadLine();
- Regex pattern = new Regex(@"(?<Didi>[^A-Za-z\-]+)|(?<Bojo>[A-Za-z]+[\-]{1}[A-Za-z]+)");
- MatchCollection matchesCollection = pattern.Matches(text);
- int turn = 1;
- foreach (Match match in matchesCollection)
- {
- var didi = match.Groups["Didi"];
- var bojo = match.Groups["Bojo"];
- if (turn % 2 == 1)
- {
- if (didi.Length == 0)
- {
- continue;
- }
- else
- {
- Console.WriteLine(didi);
- turn++;
- }
- }
- else
- {
- if (bojo.Length == 0)
- {
- continue;
- }
- else
- {
- Console.WriteLine(bojo);
- turn++;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment