求截取字符串
string name = "啊啊啊-10000元-100个";
分别截取 啊啊啊 10000 100
字符和数字长度不清楚 可能为 啊啊啊啊-2元-1个 string
[解决办法]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
string name = "啊啊啊-10000元-100个";
string []arry=new string[3];
arry[0] = name.Substring(0, name.IndexOf("-"));
arry[1] = name.Substring(name.IndexOf("-") + 1, name.IndexOf("元") - name.IndexOf("-")-1);
arry[2] = name.Substring(name.LastIndexOf("-") + 1, name.IndexOf("个") - name.LastIndexOf("-") - 1);
foreach (string i in arry)
{
Console.WriteLine(i);
}
Console.ReadKey();
}
}
}