我該如何去獲得的值,例如我的正則表達式有什麼問題?
<div class="detail"> Hello </div>
<div class="detail"> World </div>
string x = " <div class="results-list clearfix"> <div class="detail"> Hello </div> </div> <div class="results-list clearfix"> <div class="detail"> World </div> </div> "; String pattern = @"<div class=""results-list clearfix"">(?<Content>[^<]*)</div>"; Regex rx = new Regex(pattern,RegexOptions.Multiline); Match m = rx.Match(x); while (m.Success) { string zz = m.Groups["Content"].Value; m = m.NextMatch(); }
你`字符串x`值是無效的C# - 你需要使用一個逐字字符串(開始與`@`)和逃避內部引號`」 `。 – Oded 2011-02-08 13:37:11
看看這個主題。http://stackoverflow.com/questions/590747/using-regular-expressions-to-parse-html-why-not – 2011-02-08 13:46:24