string a="荐 69,255.00 (53.10%) 搜 40,845.00 (31.32%) 直 20,320.00 (15.58%) ";如上字符串,如何分别提出()括号内的三个数值并存放在数组中?
解决方案 »
- 关于"VS2008的评估期结束"后,注册显示成功,再打开仍然提示评估期结束的问题
- sms原来
- 关于 WINFORM 通过“WebService”批量上传图片问题??!!
- winform中datagridview效果变化问题
- C# 自定义表单色设计
- winform C#中 textBox1 焦点移动
- 请问,线程内部语句按不按次序执行?
- C#winform程序,在启动时怎么通过命令行方式传入参数?
- .net与连接数据库问题 高手进
- 如何把一个DataSet中表的框架复制给另外一个DataSet中的表?
- 打印时,如何监测是否打印完毕,再发送下一个打印任务
- winform矩陣數組完成三元一次方程組之解
a.split('(',')')[n];
string a = "荐 69,255.00 (53.10%) 搜 40,845.00 (31.32%) 直 20,320.00 (15.58%) ";
string Att = null;
while (a.Contains('%'))
{
Att = Att+","+a.Substring(a.IndexOf("(") + 1, a.IndexOf("%") - a.IndexOf("("));
a = a.Substring(a.IndexOf(")")+1);
}
string [] arr= Att.Trim(',').Split(',');
O(∩_∩)O哈哈~
String a = "荐 69,255.00 (53.10%) 搜 40,845.00 (31.32%) 直 20,320.00 (15.58%) ";
MatchCollection matches = Regex.Matches(a, @"\(([^\)]*?)\)");
String[] arr = new String[matches.Count];
for(int i=0;i<matches.Count;i++)
{
arr[i] = matches[i].Groups[1].Value;
}
foreach (String s in arr)
{
Console.WriteLine(s);
}
string[] aa = a.Split('(', ')');
ArrayList li = new ArrayList(aa);
for (int i = 0; i < li.Count; i++)
{
if (!li[i].Equals("%"))
{
li.Remove(li[i]);
}
}
aa = (string[])li.ToArray(typeof(string));
for (int i = 0; i < aa.Length; i++)
{
Response.Write("aa==" + aa[i] + "<br>");
}