朱丽叶

导航

替换富文本中 img标签的src地址


imgSrcReplace(htmlstr) {
  let regex3 = new RegExp(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi);
  let htmlstr1 = htmlstr.replace(regex3, function(match, capture) {
    // capture 为你匹配到的地址
    // localtionPath 为你想要拼接的地址
    let newStr = '<img src=' + localtionPath + capture + ' alt="" />';
    return newStr;
  });
  regex3 = null;
  return htmlstr1;
},

posted on 2023-01-03 17:47  朱丽叶  阅读(729)  评论(0)    收藏  举报