怎么提取这样的字符串12*36*2
分别提取 12 和 36 还有 2出来

解决方案 »

  1.   

    string aa[] = string.spilt(new char['*'])
      

  2.   

    String str = "12*36*2";
    Regex objRegex = new Regex(@"(?<First>\d+)\*(?<Second>\d+)\*(?<Third>\d+)");MatchCollection objCollection = objRegex.Matches(str);
    for (int i = 0; i < objCollection.Count; i++)
    {
        Response.Write(
            "第一个乘数:" + objCollection[i].Groups["First"].Value +
            "第二个乘数:" + objCollection[i].Groups["Second"].Value +
            "第三个乘数:" + objCollection[i].Groups["Third"].Value + "<br/>");
    }//结果为:
    //第一个乘数:12第二个乘数:36第三个乘数:2