使用正则表达式匹配a标签里,获取a标签里tilte的值
<aonclick='GoUrl('aHR0cDovL3d3dy5hbWF6b24uY24vUmVtYXgtJUU3JTlEJUJGJUU5JTg3JThGLUF...
<a onclick='GoUrl('aHR0cDovL3d3dy5hbWF6b24uY24vUmVtYXgtJUU3JTlEJUJGJUU5JTg3JThGLUFwcGxlLWlwaG9uZTUtJUU4JUI0JUI0JUU4JTg2JTlDLSVFNSVCRSVBRSVFNiU5OSVCNiVFOCU4NiU5Qy0lRTklOTglQjIlRTUlODglQUUlRTQlQkMlQTQlRTklQUIlOTglRTYlQjglODUlRTUlODklOEQlRTUlOTAlOEUlRTglQjQlQjQlRTglODYlOUMvZHAvQjAwOVFWSkdYUS9yZWY9c3JfMV81LzQ3OC0zMzI5NDc5LTg4MzYwMDg/aWU9VVRGOCZhbXA7cWlkPTEzODM1Mjg2MTUmYW1wO3NyPTgtNSZhbXA7a2V5d29yZHM9aXBob25lNSZ0YWc9c3NianctMjMmbGlua0NvZGU9dXIyJmNhbXA9NTM2JmNyZWF0aXZlPTMyMDA=')' href="#B009QVJGXQ" title='Re
max 睿量 Apple iphone5 贴膜 微晶膜 防刮伤高清前后贴膜'> Remax 睿量 Apple iphone5 贴膜 微晶膜 防刮伤高清前后贴膜 <font color="red">(2.0折,原价:49.00元)</font></a> 展开
max 睿量 Apple iphone5 贴膜 微晶膜 防刮伤高清前后贴膜'> Remax 睿量 Apple iphone5 贴膜 微晶膜 防刮伤高清前后贴膜 <font color="red">(2.0折,原价:49.00元)</font></a> 展开
1个回答
展开全部
正则表达式:<a[\s\S]*?title='([\s\S]*?)'
获取a标签里tilte的值的Javascript程序例子:
<script type="text/javascript">
var str="<a onclick='GoUrl('aHR0cDovL3d3dy5hbWF6b24uY24vUmVtYXgtJUU3JTlEJUJGJUU5JTg3JThGLUFwcGxlLWlwaG9uZTUtJUU4JUI0JUI0JUU4JTg2JTlDLSVFNSVCRSVBRSVFNiU5OSVCNiVFOCU4NiU5Qy0lRTklOTglQjIlRTUlODglQUUlRTQlQkMlQTQlRTklQUIlOTglRTYlQjglODUlRTUlODklOEQlRTUlOTAlOEUlRTglQjQlQjQlRTglODYlOUMvZHAvQjAwOVFWSkdYUS9yZWY9c3JfMV81LzQ3OC0zMzI5NDc5LTg4MzYwMDg/aWU9VVRGOCZhbXA7cWlkPTEzODM1Mjg2MTUmYW1wO3NyPTgtNSZhbXA7a2V5d29yZHM9aXBob25lNSZ0YWc9c3NianctMjMmbGlua0NvZGU9dXIyJmNhbXA9NTM2JmNyZWF0aXZlPTMyMDA=')' href=\"#B009QVJGXQ\" title='Remax 睿量 Apple iphone5 贴膜 微晶膜 防刮伤高清前后贴膜'>Remax 睿量 Apple iphone5 贴膜 微晶膜 防刮伤高清前后贴膜 <font color=\"red\">(2.0折,原价:49.00元)</font></a>";
var reg=/<a[\s\S]*?title='([\s\S]*?)'/g;
var arr=reg.exec(str);
alert(arr[1]);
</script>
获取a标签里tilte的值的Javascript程序例子:
<script type="text/javascript">
var str="<a onclick='GoUrl('aHR0cDovL3d3dy5hbWF6b24uY24vUmVtYXgtJUU3JTlEJUJGJUU5JTg3JThGLUFwcGxlLWlwaG9uZTUtJUU4JUI0JUI0JUU4JTg2JTlDLSVFNSVCRSVBRSVFNiU5OSVCNiVFOCU4NiU5Qy0lRTklOTglQjIlRTUlODglQUUlRTQlQkMlQTQlRTklQUIlOTglRTYlQjglODUlRTUlODklOEQlRTUlOTAlOEUlRTglQjQlQjQlRTglODYlOUMvZHAvQjAwOVFWSkdYUS9yZWY9c3JfMV81LzQ3OC0zMzI5NDc5LTg4MzYwMDg/aWU9VVRGOCZhbXA7cWlkPTEzODM1Mjg2MTUmYW1wO3NyPTgtNSZhbXA7a2V5d29yZHM9aXBob25lNSZ0YWc9c3NianctMjMmbGlua0NvZGU9dXIyJmNhbXA9NTM2JmNyZWF0aXZlPTMyMDA=')' href=\"#B009QVJGXQ\" title='Remax 睿量 Apple iphone5 贴膜 微晶膜 防刮伤高清前后贴膜'>Remax 睿量 Apple iphone5 贴膜 微晶膜 防刮伤高清前后贴膜 <font color=\"red\">(2.0折,原价:49.00元)</font></a>";
var reg=/<a[\s\S]*?title='([\s\S]*?)'/g;
var arr=reg.exec(str);
alert(arr[1]);
</script>
追答
正则表达式:点击";
var reg=/<a[\s\S]*?pname='([\s\S]*?)'[\s\S]*?pprice='([\s\S]*?)'[\s\S]*?plink='([\s\S]*?)'[\s\S]*?pfrom='([\s\S]*?)'/g;
var arr=reg.exec(str);
alert(arr[1]);
alert(arr[2]);
alert(arr[3]);
alert(arr[4]);
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询