简体   繁体   中英

Remove all <div> tags with a query

I want to remove all <div> tags from content, I use this query and it removes only <div> tags with no class, how to remove all <div>,<div class"example">,</div> ?

UPDATE wp_posts SET `post_content` = REPLACE (`post_content`, '<div>', '') WHERE `ID`=84259

I want a query that removes <%div%> (% means no mater what is before and after div)

You can use REGEXP_REPLACE :

update wp_posts
set post_content = REGEXP_REPLACE(post_content, '</?div.*?>', '');

Fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM