string s = "-112315-125-56()5555";

第一种方法
            MatchCollection results = Regex.Matches(s, @"[0-9]+", RegexOptions.IgnoreCase | RegexOptions.Multiline);
            string str = "";
            for (int i = 0; i < results.Count; i++)
            {
                str += results[i].Value.ToString();
            }

第二种方法

            Match result = Regex.Match(s, @"[0-9]+", RegexOptions.IgnoreCase | RegexOptions.Multiline);

            while (result.Success)
            {
                str += result.Value;
                result = result.NextMatch();
            }

posted on 2012-03-29 13:04  swarb  阅读(179)  评论(0编辑  收藏  举报