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;
- namespace ValidUsernames
- {
- class ValidUsernames
- {
- static void Main(string[] args)
- {
- string pattern = @"([A-Za-z]+)([\|\\<])(.*)([\|\\<])([A-Za-z]+)";
- string input = Console.ReadLine();
- Match myMatch = Regex.Match(input, pattern);
- string start = myMatch.Groups[1].Value;
- string end = myMatch.Groups[5].Value;
- string input2 = Console.ReadLine();
- string pattern2 = $@"{start}(.*?){end}";
- StringBuilder builder = new StringBuilder();
- MatchCollection results = Regex.Matches(input2, pattern2);
- bool isEmpty = false;
- foreach (Match m in results)
- {
- builder.Append(m.Groups[1].Value);
- }
- if (builder.Length != 0)
- {
- Console.WriteLine(builder);
- }
- else
- {
- Console.WriteLine("Empty result");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement