大家好, 在c#中如果我有一个包含大写字母的句子的字符串 我怎么能分开这些词?可能重复:
Regular expression, split string by capital letter but ignore TLA
例如:
string a = "HelloWorld"
我需要
b[0] = "Hello";
b[1]= "world";
答案 0 :(得分:4)
尝试:
String preString = "HelloWorld";
StringBuilder sb = new StringBuilder();
foreach (char c in preString)
{
if (Char.IsUpper(C))
sb.Append(' ');
sb.Append(C);
}
string result = sb.ToString();