I have a task to write a regex for a valid name. It has to consist two words, each word starts with capital letter, afterwards contains only lowercase letters, should be at least two letters long and the words are separated by a space.
string input = "Stephen King, Bruce hatow, eddie Lee, AShley Greene, Test Testov, Ann Grey";
string pattern = @"^\b[A-Z][a-z]{1,}\s\b[A-Z][a-z]{1,}$";
MatchCollection output = Regex.Matches(input, pattern);
foreach (Match item in output)
{
Console.Write(item);
}
My pattern matches only if the string has one name. e.g. string input = "Stephen King". Is there a way to do it with string or I should use List of strings and check each one of them