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.