形如*******|******,分别取"|"的前面和后面

解决方案 »

  1.   


    string str = "******* |******";
    string[]temp = str.Split('|');
    string a = temp[0];
    string b = temp[1];
      

  2.   

    string test="******* ¦******";
    string[] strlist=test.split('¦');strlist[0]的值为¦前面的字符串
    strlist[1]的值为¦后面的字符串
      

  3.   

    用Index也可以
      

  4.   

                string tmp  ="gjdfgdjkljgdf|fdlkjgldkfjgldf";
                string [] atmp ;//=new string [];
                atmp =tmp.Split('|');
                MessageBox .Show ( atmp[0]+ "" + atmp [1]);
      

  5.   


    那你如何分割??
    你想如何分割就在Split里面写什么
    Split的参数是一个char数组
    所以你可以定义多个分隔符如果你什么分隔符都没有
    难道前后位数固定??
    否则没办法取
      

  6.   

    原字符串可能是"****"或"****|****"或"*****|***|*****"或"**|***|*****|****"经过用Split函数后我想知道被分成几段??
      

  7.   

    string str = "******* |******";
    string[] temp = str.Split('|');
    都已经是数组了
    你拿一下temp的length不就知道几段了~~~`
      

  8.   

     System.Text.RegularExpressions.MatchCollection mc = null;            mc = System.Text.RegularExpressions.Regex.Matches("****************1|2*********", @"(\**)([\w])[\|]([\w])(\1)");            foreach (System.Text.RegularExpressions.Match m in mc)
                {                m.Groups[2].Value;   -- 1
                    sbm.Groups[3].Value; -- 2            }