MySql Regex Find and Replace for Wordpress
This is my first time here so excuse me if I'm missing anything.
I'm trying to perform a regex find and replace in my SQL Wordpress post content to strip out unnecessary div
and span
tags开发者_JAVA百科.
I've used this regex in text editing programs to do the same task:
<[/]?(span|div|[ovwxp]:\w+)[^>]*?>
What's the best way to approach this as an SQL query?
I don't know about running that as SQL, but Search RegEx is a good plugin to be able to search and replace with Grep through all posts and pages from the WP admin area.
You can use REGEXP_REPLACE in MySQL 8
UPDATE wp_posts
SET post_content = REGEXP_REPLACE(post_content, '<[/]?(span|div|[ovwxp]:\w+)[^>]*?>', '')
精彩评论