js 正则表达式替换字符串img的src

2021-01-21 12:13

阅读:557

标签:http   ret   span   match   spl   capture   exp   dom   new   

    imgSrcReplace(htmlstr) {
      let that = this;
      let regex3 = new RegExp(/]*src=["]([^‘"]+)[^>]*>/gi);
      let domainURL = "http://www.baidu.com/";
      let htmlstr1 = htmlstr.replace(regex3, function (match, capture) {
        console.log("capture:", capture);
        let tmp = capture.split(domainURL + "");
        capture = "http://www.amei.com" + tmp[1];
        var newStr = "" + capture +   />;
        return newStr;
      });
      regex3 = null;
      console.log("htmlstr1:", htmlstr1);
      return htmlstr1;
    },

js 正则表达式替换字符串img的src

标签:http   ret   span   match   spl   capture   exp   dom   new   

原文地址:https://www.cnblogs.com/zhaomeizi/p/13295552.html


评论


亲,登录后才可以留言!