Cleaning up Formatting Shortcodes

There are many reasons not to like Visual Composer or any other plugin that uses shortcodes for formatting purposes in the WordPress content editor. One of them is that it can be a lot of work cleaning up the mess of shortcodes that they leave if you ever decide to deactivate the plugin. But how can can remove shortcodes without painfully selecting and deleting each one?

Here is a handy regex expression that can save some time and leave you with the original unformatted content.



\[ : [ is what is known as a meta character which is used to group things in regex. for example [a-z] means a through z. In order to match it literally we need to “escape it” which can be done by using \

(.*?) : matches everything in a “non-greedy” way and captures it. You can read about different ways of matching below but basically we want to make sure that it only captures what is inside the brackets and not the content between the sets of brackets (all of our content.)

\] : Here we are escaping another meta character ] to match it literally.

That’s nice. Just tell me how to do it.

In order to do this you will need to copy the entire content of the editor into a code editor. I find Sublime Text to be the easiest to use for finding and replacing using regex expressions. You may want to check that your code editor has this functionality before proceeding. Add the expression above into the “find” input and “find all.”

Click delete. (Warning: this will delete all shortcodes!)

Admire your nice, clean, shortcode-free, content.

2 comments on “Cleaning up Formatting Shortcodes

  1. This deserves a loud golf clap as I just tried this using Sublime Text and a csv export of “visual composer” saturated content.

    Worked beautifully!

    Left a few dbl space items floating around, however nothing a little regex cleanup can’t fix. This is the most complete solution for an developer migrating content from the “lock-in” of drag/drop editors…grazie again!

Leave a Reply

Your email address will not be published. Required fields are marked *

Click to view allowed tags

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.