str = "请上传消息2的小程序封面图<span>删除消息2</span>" let str1 = str.replace(/(<\/?span.*?>)/gi,"") console.log(str1)