日期:2014-05-18 浏览次数:20560 次
string source = "你得字符串"; Regex reg = new Regex(@"</span>(?<value>[\d]?)</span>"); Match mm = reg.Match(source); MessageBox.Show(mm.Groups["value"].Value);
------解决方案--------------------
string source = "<span class=\"level\"><span class=\"textlabel\">任意长字符串,后面有空格 </span>1</span>";
Regex reg = new Regex(@"(?is)<span[^>]*><span[^>]*>.*?</span>(.*?)</span>");
Match mm = reg.Match(source);
MessageBox.Show(mm.Groups[1].Value);
------解决方案--------------------
string source = "<span class=\"level\"><span class=\"textlabel\">任意长字符串,后面有空格 </span>1</span>"; Regex reg = new Regex(@"(?is)<span[^>]*><span[^>]*>.*?</span>(.*?)</span>"); Match mm = reg.Match(source); MessageBox.Show(mm.Groups[1].Value); /* 1 */
------解决方案--------------------
string str = "<span class=\"level\"><span class=\"textlabel\">任意长字符串,后面有空格 </span>1</span>"; Regex num = new Regex(@"(?<=(<span\sclass=""textlabel"").*?(</span>)).*?</span>",RegexOptions.Singleline); Match m = num.Match(str); if (m.Success) { Response.Write(m.Value); }
------解决方案--------------------