using System.Text.RegularExpressions;
using System.Globalization;
public static void Main()
@"THE PEN IS ON THE TABLE
The cat, not the rat is UNder ThE Table (note comma)
The ChiLDreN Are ON The trampoline";
string result = Regex.Replace(text,
match => match.Value.Length > 3
? CultureInfo.CurrentCulture.TextInfo.ToTitleCase(match.Value)
: match.Value.ToUpper());