Extract title from name in c# [closed]

I would recommend regex for a clean way to get the title.

Regex regex = new Regex(@"^(Mr|Ms|Dr|Sr)\.");
Match match = regex.Match("Mr.ABC");
Console.WriteLine(match.Value);

Leave a Comment