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.RegularExpressions;
- namespace _12._ExamPreparation1
- {
- class ExamPreparation1
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine();
- string bojomonPattern = @"([A-Za-z]+)-([A-Za-z]+)";
- string didimonPattern = @"[^A-Za-z-]+";
- while (true)
- {
- Match didimon = Regex.Match(input, didimonPattern);
- if (didimon.ToString() != string.Empty)
- {
- Console.WriteLine(didimon.ToString());
- input = GetSubstring(input, didimon.ToString());
- Match bojomon = Regex.Match(input, bojomonPattern);
- if (bojomon.ToString() != string.Empty)
- {
- Console.WriteLine(bojomon.ToString());
- input = GetSubstring(input, bojomon.ToString());
- }
- }
- else
- {
- break;
- }
- }
- }
- static string GetSubstring(string input, string matchedString)
- {
- var stringPosition = input.IndexOf(matchedString);
- var stringLenght = matchedString.Length;
- var cutsFrom = stringPosition + stringLenght;
- input = input.Substring(cutsFrom);
- return input;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment