aaa<001>;bbb<002>;ccc<003>;ddd<004>;eee<005>;....类似于这样的字符串,我只想最后得到001,002,003这样的数组该如何使用SPLIT呀,动态的取值的?????????????

解决方案 »

  1.   

    1 按;分割
    2 用Substring 和Indexof 截取< >之间的内容楼上的方法最好,正则表达式-----------------------------------
    不会叫的猫
      

  2.   

    各位,我实在看不懂呀,我是刚开始学。NET的人哦,能不能给我点具体意见呢
    private void Button1_Click(object sender, System.EventArgs e)
    {
    string delimStr = "<>";
    char [] delimiter = delimStr.ToCharArray();
    string words = "aaa<001>;bbb<002>;ccc<003>;ddd<004>;eee<005>;"
    string [] split = null; for (int x = 1; x <= 5; x++) 
    {
    split = words.Split(delimiter, x); }
    string strr =split.GetValue(1).ToString(); //这里取的是001  strr =split.GetValue(3).ToString();//这里取的是002
    }
    我是取出来哪个了,但是相对于不灵活,我怎么改一些呢,输入的内容是相对于灵活的,然后在分割
      

  3.   

    ArrayList al=new ArrayList();
    string s="aaa<001>;bbb<002>;ccc<003>;ddd<004>;eee<005>;";
    int index=0,index1;
    while(index<=s.Length)
    {
    index=s.IndexOf("<",index);
    if(index==-1)
    {
    break;
    }
    index1=s.IndexOf(">",index);
    al.Add(s.Substring(index+1,index1-index-1));
    index=index1;
    }