天天看點

ASP.NET利用正規表達式提取字元串中的數字

一言不足以畢之,請LOOK代碼:

            string text = " 訂單5|本次付款:4783|本單結清,";

            string pat = @"(\d+)";

            Regex r = new Regex(pat, RegexOptions.IgnoreCase);

            Match m = r.Match(text);

            int matchCount = 0;

            while (m.Success)

            {

                ++matchCount;

                Group g = m.Groups[1];

                Response.Write("Match" + matchCount +":"+ g + "<br />");

                m = m.NextMatch();

            }

繼續閱讀