using System.Text.RegularExpressions;
private static Regex regex = new Regex("^.*\\((?<login>.*)\\)$", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
public static void Main()
Console.WriteLine(GetLogin("ZACKSON MOREIRA MORGAN (zackson.morgan)"));
Console.WriteLine(GetLogin("ZACKSON MOREIRA MORGAN (zackson.morgan"));
Console.WriteLine(GetLogin("ZACKSON MOREIRA MORGAN )"));
Console.WriteLine(GetLogin("ZACKSON MOREIRA MORGAN ("));
Console.WriteLine(GetLogin("ZACKSON MOREIRA MORGAN"));
private static string GetLogin(string input)
var res = regex.Match(input);
return res.Groups["login"].Value;
return "No matches found";