简体   繁体   中英

How to mass remove different text value within paragraph

I am totally new to this, and was wondering if there is any way how I can bulk remove certain part from WordPress posts. I have posts that contains:

<!-- wp:paragraph --><br>
<p><!--<br><strong><span style="color: #5ea5d0;"><span style="text-decoration: underline;">SOME RANDOM TEXT</span></span></strong> --></p><br>
<!-- /wp:paragraph -->

So as you can see, this text is commented < !-- >
But I have some posts that needs to display that text, and that text is always different on different posts (That's why some posts do not have it)

Is there a way to do a sql query where I can lets say do this:

UPDATE wp_posts SET post_content = replace (post_content, '<!-- wp:paragraph -->
    <p><!-- <br><strong><span style="color: #5ea5d0;"><span style="text-decoration: underline;"> SOME RANDOM TEXT</span></span></strong> --></p>
    <!-- /wp:paragraph -- >', '');

but in that matter to remove all of the commented/unnecessary parts?

If you are using Mysql 8.x, it has a REGEXP_REPLACE function. You can see official documentation here

For lower versions, you can use user defined functions like this one

Also - it is not clear whether you want to match based on SOME RANDOM TEXT OR the html tags surrounding them, or a combination of both.

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