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.RegularExpressions;
- public class Example
- {
- public static void Main()
- {
- List<string> validWords = new List<string>();
- string input = Console.ReadLine();
- string pattern = @"([=,]|[\/,])(?<Match>[[A-Z]{1}[a-z]{3,})(\1)";
- MatchCollection matches = Regex.Matches(input, pattern);
- int matchedWordsCount = 0;
- int totalLenghtOfMatches = 0;
- foreach (Match match in matches)
- {
- var word = match.Groups["Match"].Value;
- totalLenghtOfMatches += word.Length;
- validWords.Add(word);
- matchedWordsCount++;
- }
- if (matchedWordsCount >= 1)
- {
- Console.WriteLine("Destinations: " + string.Join(", ", validWords));
- Console.WriteLine("Travel Points: " + totalLenghtOfMatches);
- }
- else
- {
- Console.WriteLine("Destinations: " + string.Join(", ", validWords));
- Console.WriteLine("Travel Points: " + totalLenghtOfMatches);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement