以下是网页源码:
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>济南天气预报-今日_明日_一周天气预报:15日星期六 晴 20/12℃ </title><meta http-equiv='X-UA-Compatible' content='IE=7' /><meta http-equiv="Content-Language" content="zh-cn">
另外,请老大说说怎么学习正则表达式?总是感觉没弄懂
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>济南天气预报-今日_明日_一周天气预报:15日星期六 晴 20/12℃ </title><meta http-equiv='X-UA-Compatible' content='IE=7' /><meta http-equiv="Content-Language" content="zh-cn">
另外,请老大说说怎么学习正则表达式?总是感觉没弄懂
string str = @"<html xmlns=""http://www.w3.org/1999/xhtml""><head><meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"" /><title>济南天气预报-今日_明日_一周天气预报:15日星期六 晴 20/12℃ </title><meta http-equiv='X-UA-Compatible' content='IE=7' /><meta http-equiv=""Content-Language"" content=""zh-cn"">";
Regex reg = new Regex(@"(?is)(?<=<title>)(?:(?!</title).)*");
Console.WriteLine(reg.Match(str).Value);
string str = @"<html xmlns=""http://www.w3.org/1999/xhtml""><head><meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8"" /><title>济南天气预报-今日_明日_一周天气预报:15日星期六 晴 20/12℃ </title><meta http-equiv='X-UA-Compatible' content='IE=7' /><meta http-equiv=""Content-Language"" content=""zh-cn"">";
Regex reg = new Regex(@"(?is)(?<=<title>)(?:(?!</title).)*");
Console.WriteLine(reg.Match(str).Value);