正则表达式

正则替换,给图片加懒加载属性
content = content.replace(/[video]*?src=['"]([^'"]+)[^>]*>/gi, VIDEO_BASE_SRC + "$1\" " + 'webkit-playsinline playsinline />');
content = content.replace(/<img.*?(?=src)src=['"]([^'"]+)[^>]*>/gi, '<img ' + BASE_SRC + "$1\" class=\"lazy\" " + LOADING_SRC + '/>');
posted @ 2018-07-10 14:30  公子秦1117  阅读(96)  评论(0编辑  收藏  举报