Finding Email Addresses within WordPress Content using WP-CLI

We recently needed to see all the email addresses mentioned within the content on a WordPress site. Below is the WP-CLI command we used to find the email addresses in the database using a bit of REGEX and some WP CLI db search flags.

wp db search '([a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)' --regex --matches_only wp_posts

Probably some ways to do things better with the output and such. Please comment if you improve it!

Exit mobile version