using System.Collections.Generic;
using System.Text.RegularExpressions;
public static void Main()
var pattern = @$"({search})";
Console.WriteLine(pattern);
var persons = Persons.GetAll();
var results = new List<Person>();
foreach (var person in persons)
if (Regex.IsMatch(person.Name, pattern, RegexOptions.IgnoreCase))
if (Regex.IsMatch(person.Surname, pattern, RegexOptions.IgnoreCase))
Console.WriteLine("Search results:");
Console.WriteLine("----------------");
foreach (var item in results)
Console.WriteLine($"{item.Name} {item.Surname}");
public string Name { get; set; }
public string Surname { get; set; }
public static class Persons
public static List<Person> GetAll()
var people = new List<Person>{
new Person { Name = "Paul", Surname = "Cook" },
new Person { Name = "Dade", Surname = "Murphey" },
new Person { Name = "Kate", Surname = "Libby" },
new Person { Name = "Emmanuel", Surname = "Goldstein" },
new Person { Name = "Eugene", Surname = "Belford" },
new Person { Name = "Ramon", Surname = "Sanchez" },
new Person { Name = "Joey", Surname = "Pardella" },
new Person { Name = "Lauren", Surname = "Murphey" }