62,072
社区成员
发帖
与我相关
我的任务
分享
using System.Text.RegularExpressions;
string text = "<div class=\"newsInfo\">点击数:12 日期:2017-03-17 10:15 作者:</div>";
string pattern = @"\d{4}-([0][1-9]|[1][12]|[1-9])-([0][1-9]|[12][0-9]|[3][01]|[1-9])";
Regex rgx = new Regex(pattern);
Match mc = rgx.Match(text);
string date = "";
if (mc.Success)
{
date = mc.Value;
}