我要把 字符串AABED1234 中的数字提取出来,怎么办?

解决方案 »

  1.   


    Public string GetNum(string ss)
    {
       string s = ss;
       string sNum = "";
       for (int i = 0; i < s.Length; i++)
       {
           char c = s[i];
           if (c>=48 && c<=57)
           {
              sNum += c;
           }
       }
       return sNum;
    }
      

  2.   

    try {
    Regex RegexObj = new Regex("\\d");
    Match MatchResults = RegexObj.Match(SubjectString);
    while (MatchResults.Success) {

    MatchResults = MatchResults.NextMatch();

    } catch (ArgumentException ex) {
    // Syntax error in the regular expression
    }