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.Text.RegularExpressions;
- using System.Threading.Tasks;
- public class Ex
- {
- public static void Main()
- {
- string text = Console.ReadLine();
- string pattern = @"(?:^|\W)([a-z][\w]{2,24})";
- Regex regex = new Regex(pattern);
- MatchCollection matches = regex.Matches(text);
- int len = 0;
- int maxLen = int.MinValue;
- string firstUsername = "";
- string secondUsername = "";
- for (int i = 0; i < matches.Count - 1; i++)
- {
- len = matches[i].Groups[1].Length + matches[i + 1].Groups[1].Length;
- if (len > maxLen)
- {
- maxLen = len;
- firstUsername = matches[i].Groups[1].ToString();
- secondUsername = matches[i + 1].Groups[1].ToString();
- }
- }
- Console.WriteLine(firstUsername);
- Console.WriteLine(secondUsername);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement