using System.Collections.Generic;
public static void Main()
string[] lines = { "Hi, I'm Bobby", "My name is Rod Stewart", "Nice to meet you, im Andrew...",
"I am Lucy it's nice to meet you", "im stewart, how are you doing?", "There's no name here", "Hi I'm nobody" };
foreach (string s in lines)
Console.WriteLine(string.Format("{0} => {1}", s, ParseName(s)));
System.Console.WriteLine("Press any key");
System.Console.ReadLine();
public static string ParseName(string aText)
var tmpWords = aText.Split(new char[5] {' ', '`', '\'','.', ','});
foreach (string s in tmpWords)
String.Equals(s, "NO", StringComparison.OrdinalIgnoreCase) ||
String.Equals(s, "NOBODY", StringComparison.OrdinalIgnoreCase)
if (String.Compare(s.ToUpper(), "M")==0 ||
String.Compare(s.ToUpper(), "S")==0 ||
String.Compare(s.ToUpper(), "AM") == 0 ||
String.Compare(s.ToUpper(), "IM") == 0 ||
String.Compare(s.ToUpper(), "IS")==0)