我想要一个这样的字符串:" TEMporADA DOS TECNologoS"
将成为:" Temporada dos Tecnologos"。
由于
答案 0 :(得分:2)
不需要正则表达式。您可以先使用TextInfo.ToTitleCase
,然后在"忽略" -words:
string text = "TEMporADA DOS TECNologoS";
string[] ignoreWords = {"dos", "de", "da"};
text = System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text); // uppercase first letter all
var newWords = text.Split()
.Select(w => ignoreWords.Contains(w, StringComparer.OrdinalIgnoreCase)
? Char.ToLower(w[0]) + w.Substring(1)
: w);
text = String.Join(" ", newWords);