正则 群组 Group

  static void Main(string[] args)
        {
            string strUrl = "<a href="user.php?act=order_detail&order_id=425044" target="_blank" class="J_MakePoint status">未付款</a> ";
            var s=GetHTOrderId(strUrl);
            //取到:order_id=425044
            Console.Read();
        }

        private static string GetHTOrderId(string linkUrl)
        {
            string pattern = "<a href="user.php?(?<A>.+?)&(?<orderID>.+?)".*>(?<B>.+?)</a>";
            Regex rr = new Regex(pattern, RegexOptions.IgnoreCase);
            MatchCollection matches = rr.Matches(linkUrl);

            foreach (Match match in matches)
            {
                return match.Groups["orderID"].Value ;
            }
            return "";
        }
原文地址:https://www.cnblogs.com/ChineseMoonGod/p/5337037.html