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 ""; }
时间: 2024-10-10 23:22:28