使用C ++ / CLI将System :: String ^拆分为多个分隔符

时间:2014-02-17 13:24:48

标签: c++-cli string-parsing

我是C ++ / CLI的新手,正在尝试拆分带有多个分隔符的System::String^

System::String^ = 65 kb (65,546 bytes)
Split
System::String^ = 65546

我发现此代码很棒,但它仅适用于std::string,我不允许转换System::String^

std::string s = "65 kb (67,873 bytes)";
std::string delimiter = " (";

size_t pos = 0;
std::string token;
while ((pos = s.find(delimiter)) != std::string::npos) {
    token = s.substr(0, pos);
    std::cout << token << std::endl;
    s.erase(0, pos + delimiter.length());
}

关于如何做到这一点的任何想法?

1 个答案:

答案 0 :(得分:0)

您正在使用.NET类(System.String)。您需要.NET答案:Does C# have a String Tokenizer like Java's?

相关问题