zoukankan      html  css  js  c++  java
  • 正则表达式:提取刷新时间和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

  • 相关阅读:
    4.22课堂
    4.21课堂
    4.20作业
    4.20课堂
    4.17课堂
    4.16课堂
    4.15作业
    4.15反射与内置方法
    4.10绑定与非绑定
    70、django中间件
  • 原文地址:https://www.cnblogs.com/wang7/p/2783972.html
Copyright © 2011-2022 走看看