如题 a231cc     123提取123  求解

解决方案 »

  1.   

    string "a231cc    123"提取123??
      

  2.   

    只是要123吗?中间有空格的话就用string.split(' ')
      

  3.   

          string var = "a231cc";
                byte[] dat = System.Text.Encoding.Default.GetBytes(var);
                string number = "";
                foreach (byte b in dat)
                {
                    if (b > 47 && b < 58)
                    {
                        number = number + (char)b;
                    }
                }
      

  4.   

    string a="a231cc 123"提取123出来
      

  5.   

    string a ="a123cc";
    string bb =String.Empty;
    byte[] _b = System.Text.Encoding.ASCII.GetBytes(a);
    foreach(byte b in _b)
    {
    if (b>47 && b<58)
    {
    bb = bb+(char)b;
    }
    }
    Console.WriteLine(bb);
      

  6.   


    中间有空格,用分割!string a="a231cc 123";
    string str;
    string[] strs=a.split(' ');
    str=strs[1].tostring();
      

  7.   

    using System.Text.RegularExpressions;
    string str = "a231cc    123";
    MatchCollection mc = Regex.Matches(str, @"[0-9]+");
    Console.WriteLine(mc[mc.Count-1].ToString());
    /*
    123
    请按任意键继续. . .
    */
      

  8.   


    string test = "a231cc    123";
    Match m = Regex.Match(test, @"(?<=\s)(\d+)(?=[^0-9]?)", RegexOptions.IgnoreCase);
    if (m.Success) Response.Write(m.Value);