string str="<p class=\"sms\" mid=\".*\" type=\".*\"><a name=\".*\"></a><a href=\".*\" title=\".*\" target=\".*\">XXX</a>:(?<content>(\\w|\\W)*?)</p>";
string html=".....";
Regex regex = new Regex(str, RegexOptions.Multiline | RegexOptions.IgnoreCase);
Match mc = regex.Match(html);
if (mc.Success)
return mc.Groups[ "content"].Value; 在html中有两个 str类型的p标签
现在每次获取的都是后面一个p标签内的内容 怎么可以获取第一次匹配到的内容啊
要获取第一个?
string html=".....";
Regex regex = new Regex(str, RegexOptions.Multiline | RegexOptions.IgnoreCase);
foreach( Match mc in regex.Matches(html))
{
if (mc.Success)
Console.WriteLine(mc.Groups[ "content"].Value);
}
html中第二个p标签的class 并不等于sms 但是他还是取的 第二个p标签中的内容
这是怎么回事哦
求解啊. . ..
第一个p标签的class=sms 第二个p标签的class=source
我想匹配到第一个p标签里的内容 但他返回的总是第二个里面的 如果html中只有一个p标签时 返回的就是正常的