JS 获取Html字符串中的img标签替换src内容『转』
<script type="text/javascript"> var newContent= content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi,function(match,capture){ //capture,返回每个匹配的字符串 var newStr='<img src="http://www.csghj.gov.cn'+capture+'" alt="" />'; return newStr; }); console.debug(newContent); </script>
转自:http://blog.csdn.net/burongwawa520/article/details/46562015