内容如:尺寸100*200
尺寸1200*300的架子, 尺寸1200*200的桌子
尺寸2400*1000
3200*1600
尺寸2400*1500,没有大尺寸*5
尺寸1100*400的架子, 尺寸1500*200的桌子,尺寸300*150的椅子
希望提取的结果:
100*200
1200*200 (说明:有多个型号,就取最后1个)
2400*1000
3200*1600
2400*1500
300*150

解决方案 »

  1.   

    private void button7_Click(object sender, EventArgs e)
    {
        string[] Detail = new string[] { 
            "尺寸100*200", 
            "尺寸1200*300的架子, 尺寸1200*200的桌子", 
            "尺寸2400*1000", 
            "3200*1600", 
            "尺寸2400*1500,没有大尺寸*5", 
            "尺寸1100*400的架子, 尺寸1500*200的桌子,尺寸300*150的椅子"
        };
        for (int i = 0; i < Detail.Length; i++)
        {
            string aDetail = Detail[i];
            string[] sDetail = aDetail.Replace(" ", "").Split(',');
            for (int j = 0; j < sDetail.Length; j++)
            {
                string asDetail = sDetail[j];
                string tempDetail = "";
                for (int k = 0; k < asDetail.Length; k++)
                {
                    if (asDetail[k] >= '0' && asDetail[k] <= '9' || asDetail[k] == '*')
                        tempDetail += asDetail[k];
                }
                sDetail[j] = tempDetail;
            }        for (int j = sDetail.Length - 1; j >= 0; j--)
            {
                string asDetail = sDetail[j];
                if (asDetail[0] != '*')
                {
                    textBox6.Text += asDetail + "\r\n";
                    break;
                }
            }
        }
    }