string text = "try your {{equal|even out|regularize} out|steady|tied|equal}";
实际上我想拆分外括号内的所有单词({}
)。
例如,如果这是字符串:"{{equal|even out|regularize} out|steady|tied|equal}"
,我希望拆分结果数组为:
{相等,
在外面,
正规化,
出,
稳定,
捆绑,
等于}
string text = "try your {{equal|even out|regularize} out|steady|tied|equal} {champion|finest|top-quality}";
string1 = "try";
string2 = "your";
string3="{{equal|even out|regularize} out|steady|tied|equal}";
string4="{champion|finest|top-quality}";
如何像这样分开......请帮助我......谢谢!
答案 0 :(得分:1)
试试这个:
string text = "try your {{equal|even out|regularize} out|steady|tied|equal}";
text = text.Remove(0, text.IndexOf('{'));
var array = text.Split('{', '}', '|');
array.ToList().ForEach(item =>
{
Console.WriteLine(item);
});
输出:
equal
even out
regularize
out
steady
tied
equal