C#正则表达式匹配“换行\回车”等问题

C# 正则表达式 换行\回车 问题

string s = ".......";
string r = @"(?s)(?i)导演:\s*</span>\s*<span\s+class=""m_c"">\s*<span& gt;<a.*?>(?<director>.*?)</a>";
string t = Regex.Match(s, r).Groups["director"];
Console.WriteLine(t);
// (?s) 点号匹配一切字符(含换行符)
// (?i) 进行不区分大小写的匹配
// (?<name>...) 命名捕获

Regex r = new Regex("(?s)(?i)id=\"__VIEWSTATE\" value=\"(?<__VIEWSTATE>[^\"]+)\" />.+" +
"<span id=\"lbinfo\">(?<lbinfo>[^<]+)</span>.+" +
"<span id=\"lbIP\">(?<lbIP>[^<]+)</span>.+" +
"<span id=\"lbuserid\">(?<lbuserid>[^<]+)</span>.+" +
"<span id=\"lbRealName\">(?<lbRealName>[^<]+)</span>.+" +
"<span id=\"lbRemainMoney\">(?<lbRemainMoney>[^<]+)</span>.+" +
"<span id=\"lbFreshTime\">(?<lbFreshTime>[^<]+)</span>.+" +
"<span id=\"LNowState\">(?<LNowState>(开放|关闭)IP成功).+</span>.+" +
"id=\"__EVENTVALIDATION\" value=\"(?<__EVENTVALIDATION>[^\"]+)\" />", RegexOptions.Compiled);

 

posted @ 2013-01-03 17:49  曾是土木人  阅读(4189)  评论(0编辑  收藏