如何在C#中用支架拆分字符串? [英] How to Split String with Bracket in C# ?
本文介绍了如何在C#中用支架拆分字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨朋友们,
请告诉我如何解决这个问题...'
我有一些字符串说
string str = ELSPending(250);
string str2 = 正在进行的工作( 10);
i想从中取250和10请帮助我!
提前致谢
Shreeniwas Kushwah
解决方案
最简单的方法是使用正则表达式:
(?:\()\d +(?:\))应该这样做。
试试这个:
str.Split(new string [] {(,)},StringSplitOptions.RemoveEmptyEntries );
嗨sheeniwas,
试试这个,它可能对你有帮助。
string str = 工作在进展(10)跨度>;
int pos1 = str.IndexOf( ();
int pos2 = str.IndexOf( )跨度>);
int lenth = pos2 - pos1;
string newstr = str.Substring(pos1 + 1,lenth-1);
newstr在这种情况下会给你10个
如果有帮助请将其标记为答案。
问候
SUNIL
Hi Friends,
Please Tell me How to resolve this problem ...'
I have some string say
string str = "ELSPending(250)";
string str2 = "Work In Progress(10)";
i want to take 250 and 10 from it please help me!
Thanks in advance
Shreeniwas Kushwah
解决方案
Easiest way is to use a regex:
(?:\()\d+(?:\))should do it.
Hi,
Try this:
str.Split(new string[]{"(",")"},StringSplitOptions.RemoveEmptyEntries);
Hi sheeniwas,
Try this, it might help you.
string str = "Work In Progress(10)"; int pos1 = str.IndexOf("("); int pos2 = str.IndexOf(")"); int lenth = pos2 - pos1; string newstr = str.Substring(pos1+1, lenth-1);
newstr will give you 10 in this case
If it is helpfull please mark it as answer.
Regards
SUNIL
这篇关于如何在C#中用支架拆分字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文