在数据库中如何用通配符批量替换

哪位同学帮我看下,下面这段代码在数据库中如何批量替换?alt后面的内容不同,需要用通配符,谢谢

<img class="j-lazy" style="width: 100%;" alt="这里是中文,每段内容不同" />

试过以下方法,不好用

update wp_posts SET post_content=REPLACE(post_content,'^<img class=\"j-lazy\" style=\"width: 100%;\" alt=\"*$\" \/>','')


为什么要替换,是存不进去吗?
post_content 这个字段类型换成text
富文本的数据格式都能存进入,包括你说的这个网页标签等

如果是想要存文字,不需要标签等符号也可以解决
如下:

function getSimpleText(html){
 
 //匹配html标签的正则表达式,"g"是搜索匹配多个符合的内容
var re1 = new RegExp("<.+?>","g")
 
//执行替换成空字符
var msg = html.replace(re1,'')
return msg;
}

update wp_posts set post_content = regexp_replace(post_content,'<img.*/>','');

需求:要在mysql中批量删除字段列字符串中这段 <img。。。/>内容
说明:我这边试验是好用的,建议题主事先备份表再运行。

update wp_posts 
inner join 
    (select *,REPLACE(post_content, img, '') as rep from (
            select *,SUBSTRING(post_content, instr(post_content,'<img class=\"j-lazy\" style=\"width: 100%;\" alt=\"'), instr(post_content,'\" \/>') - instr(post_content,'<img class=\"j-lazy\" style=\"width: 100%;\" alt=\"') + 4) as img
            from wp_posts
        ) as t
    ) as t2
on t2.post_content = wp_posts.post_content
set wp_posts.post_content = t2.rep