You are viewing a single comment's thread. Return to all comments →
C#
using System.Text.RegularExpressions;
int N = int.Parse(Console.ReadLine()); List names = new List();
Regex gmailPattern = new Regex(@"@gmail.com$");
for (int i = 0; i < N; i++) { var parts = Console.ReadLine().Split(' '); string firstName = parts[0]; string emailID = parts[1];
if (gmailPattern.IsMatch(emailID)) names.Add(firstName);
}
foreach (var name in names.OrderBy(n => n)) Console.WriteLine(name);
Seems like cookies are disabled on this browser, please enable them to open this website
Day 28: RegEx, Patterns, and Intro to Databases
You are viewing a single comment's thread. Return to all comments →
C#
using System.Text.RegularExpressions;
int N = int.Parse(Console.ReadLine()); List names = new List();
Regex gmailPattern = new Regex(@"@gmail.com$");
for (int i = 0; i < N; i++) { var parts = Console.ReadLine().Split(' '); string firstName = parts[0]; string emailID = parts[1];
}
foreach (var name in names.OrderBy(n => n)) Console.WriteLine(name);