用特殊字符分割文本 [英] Split text with special character
本文介绍了用特殊字符分割文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在下面分割文字:
} xxxix,{†‡ƒ«. :›¢øñ
如何在字符"{"和}}"以及其他文本之间分割文本?
我使用泛型.
此文字是动态的
请帮助我.
Hi,
I want split text below:
}xxxix,{ †‡ƒ«. :›¢øñ
How can I split text between characters ''{'' and ''}'' and other text?
I use generic.
This text is dynamic
Please help me.
推荐答案
为什么不那样尝试
Why dont you try like that
string ss = "}xxxix,{ †‡ƒ«. :›¢øñ";
char[] c = { ''}'', ''{'' };
ss.Split(c);
我不会使用正则表达式,只使用String.Split两次:
I wouldn''t use a regex, just String.Split twice:
string text = "›¢øñ}xxxix,{ †‡ƒ«. :›¢øñ";
string[] withoutClose = text.Split(''}'');
if (withoutClose.Length == 2)
{
string[] withoutOpen = withoutClose[1].Split(''{'');
if (withoutOpen.Length == 2)
{
string start = withoutClose[0];
string middle = withoutOpen[0];
string end = withoutOpen[1];
}
}
这篇关于用特殊字符分割文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文