Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Text.RegularExpressions;
- namespace Task_3_RegexMon
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string bojomon = @"([a-zA-Z]+)(-+)([a-zA-Z]+)";
- string didimon = @"[^-a-zA-Z]+";
- MatchCollection bojoMatch = Regex.Matches(input, bojomon);
- MatchCollection didiMatch = Regex.Matches(input, didimon);
- List<Match> list = new List<Match>();
- int counter = Math.Min(bojoMatch.Count, didiMatch.Count);
- for (int c = 0; c< counter; c++)
- {
- list.Add(didiMatch[c]);
- list.Add(bojoMatch[c]);
- }
- if (bojoMatch.Count>didiMatch.Count)
- {
- list.Add(bojoMatch[bojoMatch.Count-1]);
- }
- else if (bojoMatch.Count < didiMatch.Count)
- {
- list.Add(didiMatch[didiMatch.Count - 1]);
- }
- foreach (Match element in list)
- {
- Console.WriteLine(element);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement