62,073
社区成员
发帖
与我相关
我的任务
分享
Regex reg1 = new Regex(@"(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229)");
String str2 = "http://news.qq.com/a/20100817/000976.htm";
if(reg1.IsMatch(str2))
Console.WriteLine("True");
else
Console.WriteLine("False");
protected void Page_Load(object sender, EventArgs e)
{
string s1 = "http://news.sina.com.cn/c/2010-08-12/004720877716.shtml";
string s2 = "http://survey.news.sina.com.cn/list.php?channel=news&dpc=1";
bool b1= check(s1);
bool b2= check(s2);
Response.Write(b1.ToString()); //true;
Response.Write(b2.ToString()); //false;
}
bool check(string s)
{
s = s.Replace("http://", "");
string[] ss = s.Split(new char[] { '/', '.', '?', '&' ,'='});
int i = 0;
foreach (string s1 in ss)
{
try
{
DateTime dt = DateTime.Parse(s1);
}
catch
{
i++;
}
}
if (i == ss.Length)
{
return false;
}
else
{
return true;
}
}
Regex reg = new Regex(@"(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})-(((0[13578]|1[02])-(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)-(0[1-9]|[12][0-9]|30))|(02-(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))-02-29)");
String str = "http://news.sina.com.cn/c/2010-08-12/004720877716.shtml";
if (reg.IsMatch(str))
Console.WriteLine("True");
else
Console.WriteLine("False");