using System.Text.RegularExpressions;
public static void Main()
"HelloManyPeopleOfTheWorld",
foreach (string str in strs)
Console.WriteLine("str: " + str);
string a = ToSentenceCaseA(str);
string b = ToSentenceCaseB(str);
Console.WriteLine("a: " + a);
Console.WriteLine("b: " + b);
Console.WriteLine("\n\n");
public static string ToSentenceCaseA(string str)
if (str.ToUpper().Replace(" ", "") == str)
return Regex.Replace(str, "(\\B[A-Z]+)", " $1".ToLower());
public static string ToSentenceCaseB(string str)
if (str.ToUpper().Replace(" ", "") == str)
return Regex.Replace(str, "(\\B[A-Z]+)", m => " " + m.ToString().ToLower());