Possible Duplicate:
Regular expression, split string by capital letter but ignore TLA




大家好,
在c#中,如果我有一个包含大写字母的句子字符串
我如何拆分单词?

例如:

string a = "HelloWorld"


我需要

b[0] = "Hello";
b[1]= "world";

最佳答案

尝试:

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();

关于c# - C#字符串问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4422266/

10-13 07:37