网页源码中含有
<a class="cur" id="prePage" href="/bh/gg/18-55/p/1325606664948/" onclick="return go($('#prePage'),'p','/bh/gg/18-55/p/1325606664948/');"><<上一页 </a> <a class="cur" id="nextPage" href="/bh/gg/18-55/n/1325554658899/" onclick="return go($('#nextPage'),'n','/bh/gg/18-55/n/1325554658899/');">下一页 >></a><a target="_blank" href="/user/4130797266183">我要取出
/bh/gg/18-55/p/1325606664948/
/bh/gg/18-55/n/1325554658899/
/user/4130797266183中的4130797266183请教代码!
<a class="cur" id="prePage" href="/bh/gg/18-55/p/1325606664948/" onclick="return go($('#prePage'),'p','/bh/gg/18-55/p/1325606664948/');"><<上一页 </a> <a class="cur" id="nextPage" href="/bh/gg/18-55/n/1325554658899/" onclick="return go($('#nextPage'),'n','/bh/gg/18-55/n/1325554658899/');">下一页 >></a><a target="_blank" href="/user/4130797266183">我要取出
/bh/gg/18-55/p/1325606664948/
/bh/gg/18-55/n/1325554658899/
/user/4130797266183中的4130797266183请教代码!
string pattern = @"(?i)<a[^>]*href=(['""]?)([^'""]+)\1.*?>";
foreach (Match m in Regex.Matches(tempStr, pattern))
{
//循环输出
string value = m.Groups[2].Value;
/* 匹配内容
/bh/gg/18-55/p/1325606664948/
/bh/gg/18-55/n/1325554658899/
*/
}
string str = "<a target=\"_blank\" href=\"/user/4130797266183\">";
str = Regex.Match(str, @"<a[^>]+href=(['""]?).*?(\d+)\1.*?>").Groups[2].Value;//4130797266183