有一个字符串“0228352634293806”,我现在想要获取“28”和“29”的字符,求解

解决方案 »

  1.   

    可以用string.indexof()结合string.substring()来获取。
      

  2.   

    到MSDN看string类,各种操作string的方法都有。
    你的字符串要找固定位置字符的话就用String.Substring 方法 (Int32, Int32)
      

  3.   

    如果长度固定用indexof+substring()就可以了
    如果不固定 就的写正则表达式
      

  4.   

        string str = "0228123123352634293806";
                string str1 = "";
                int  index1 = str.IndexOf("28");            int index2 = str.IndexOf("29");
                if (index1 != -1||index2!=-1) 
                {
                     str1 = str.Substring((index1+2), (index2-(index1+2)));
                }
    前提是知道28在29前面的