JavaScript查找Html字符串中的img标签替换src属性的内容

JavaScript示例代码如下:

 var newContent= content.replace(/]*src=['"]([^'"]+)[^>]*>/gi,function(match,capture){

  //capture,返回每个匹配的字符串
        var newStr='';
         return newStr;
  });
   console.debug(newContent);


具体知识点参考网址:

 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace


你可能感兴趣的:(web前端)