Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Numerics;
- using System.Text;
- using System.Text.RegularExpressions;
- namespace Feb26_2018
- {
- class MainClass
- {
- /* The input will consist of a single line, containing the text,
- * that Bojomon and Didimon are going to match. */
- public static void Main()
- {
- var patternBojo = @"\b([A-Za-z]+-[A-Za-z]+)\b";
- var patternDidi = @"[^A-Z[a-z-]";
- var input = "^^^^pika-pika^^^^";//Console.ReadLine();
- //char[] sep = {'\S'};
- // var inputSplit = input.Split(sep, StringSplitOptions.RemoveEmptyEntries);
- //string separ = @"\w";
- //string[] splitInput = Regex.Split(input, separ);
- //Console.Write(string.Join(", ", splitInput));
- //var inputSplitByDidi = input.Split(patternDidi);
- //Match matchBojo = patternBojo.Match(input);
- var matchDidi = Regex.Matches(input, patternDidi);
- var matchBojo = Regex.Matches(input, patternBojo);
- Regex didi = new Regex(patternDidi);//patternDidi
- Regex bojo = new Regex(patternBojo);
- bool inputHasDidi = didi.IsMatch(input);
- bool inputHasBojo = bojo.IsMatch(input);
- MatchCollection matchedDidi = didi.Matches(input);
- MatchCollection matchedBojo = bojo.Matches(input);
- foreach(var item in input)
- {
- if (inputHasDidi)
- {
- foreach (var did in matchedDidi)
- {
- Console.Write(did);
- }
- }
- else if (inputHasBojo)
- {
- foreach (var boj in matchedBojo)
- {
- Console.Write(boj);
- }
- }
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement