正则表达式:提取刷新时间和webid

1,提取刷新时间

   #region 根据刷新时间判断是否发布或者刷新成功
        //匹配源:  <p>刷新时间:2012-11-22 16:30</p>
        //需要获取: 2012-11-22 16:30
        private bool TestRefreshTime(string input)
        {
            bool flag = false;           
            //正则 \d+至少一个数字,\-转义连接符,\s空格,()分组
            Regex regex = new Regex(@"刷新时间:(\d+\-\d+\-\d+\s+\d+:\d+)");
            Match match = regex.Match(input);
            if (match.Success) 
            {
                DateTime time1 = DateTime.Now;//本地时间
                DateTime  time2 = Convert.ToDateTime(match.Groups[1].ToString());
                if (Math.Abs((time1 - time2).TotalMinutes) > 5)
                {
                    flag = false;
                }
                else
                {
                    flag = true;
                }
            }            
            return flag;
        }
        #endregion

2,提取webid

原文地址:https://www.cnblogs.com/wang7/p/2783972.html