• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

PenguinWP

Digital Marketing & WordPress Guides, Tips & Tutorials

  • WORDPRESS
    • Plugins
    • Themes
    • Hosts
  • MARKETING
    • Affiliate Marketing
    • Digest
    • Domains
    • Email Marketing
    • Google AMP
    • Google Analytics
    • Google Tag Manager
    • How To
    • SEO
    • Social Media
    • Tools
  • TOOLS
    • WP Author Bio – Free WordPress Plugin
    • WPSNIFFER – Free Chrome Extension
  • CONTACT
You are here: Home / WordPress / Don’t waste your f(.*?)king time, use Search Regex

Don’t waste your f(.*?)king time, use Search Regex

January 11, 2016 By Andy Forsberg 6 Comments

Don’t waste your f(.*?)king time, use Search Regex
Tweet
Share
Share
Reddit
Buffer

Search Regex is an amazing free WordPress plugin that enables you to search and replace code throughout your WordPress site. It can save an insane amount of time if used properly. The use cases for it are countless. To give you an idea of how useful it can be and inspire you to think about how you can leverage the tool, I’ve provided some specific examples of how I’ve used it below.


Select entire shortcode

Search pattern

1
[\[button.*\]]

Select entire button shortcode with Search Regex
The above search pattern will return all instances of [button] shortcodes on your site. This could be useful if for example you wanted to remove legacy shortcodes throughout your site.


Add a shortcode surrounding all images

Search pattern

1
[<img(.*?)>]

Replace pattern

1
[et_social_share_media]<img$1>[/et_social_share_media]

Add shortcode surrounding all images with Search Regex
The above example would add the Elegant Themes social share media shortcode for the Monarch social media sharing WordPress plugin to all images on your site. Just imagine how much time it would take to do that manually for 353 images!


Remove all links to a particular domain

Search pattern

1
[<a(.*?)href="(.*?)://domain.com/(.*?)>(.*?)]

Replace pattern

1
$4

Remove all links to a domain with Search Regex
The above example would select all links pointing to domain.com and remove the links while keeping the anchor text, effectively removing all links on your site pointing to domain.com.


Convert shortcode buttons to HTML buttons

Search pattern

1
[\[vc_button title="(.*?)"(.*?)href="(.*?)"\]]

Replace pattern

1
[<a href="$3" class="button color-3 large">$1</a>

Convert shortcode buttons to HTML buttons with Search Regex
The above example would convert all visual composer buttons from shortcodes to HTML buttons. It simply moves the link URL and the anchor text to the correct position in the new link tag and adds the classes used for the HTML button.


Other uses for Search Regex?

If you need help figuring out how to use it effectively on your site, let me know what you want to do in the comments and I’ll see if I can help you do just that. If you have other ways to use this amazing plugin I’d love to hear about them!

Tweet
Share
Share
Reddit
Buffer

Related Content:

  • 27 Advanced Segment Templates for Google Analytics27 Advanced Segment Templates for Google Analytics
  • Moving WordPress to HTTPS with Let’s EncryptMoving WordPress to HTTPS with Let’s Encrypt
  • 7 Common Google Analytics UTM URL Tracking Mistakes To Avoid7 Common Google Analytics UTM URL Tracking Mistakes To Avoid
  • How To Manually Update WordPress Themes ElegantlyHow To Manually Update WordPress Themes Elegantly

About Andy Forsberg

Andy Forsberg works at FRSecure and SecurityStudio on Vendor Risk Management Software and other projects as the Digital Marketing Director. He is known for his Analytics, HubSpot, Salesforce, SEM, SEO & WordPress expertise. Andy created the WP Author Bio WordPress Plugin and WPSNIFFER Chrome extension.

Follow Andy on:
LinkedIn | Twitter | WordPress | ManageWP.org

Reader Interactions

Comments

  1. Akash Gurnani says

    February 18, 2016 at 4:11 pm

    Search Regex! It sounded very difficult at first But you explained it very nicely and made it easy.

    Reply
  2. Tech Savvy Guy says

    March 22, 2016 at 11:42 pm

    You made it quite easy to understand. Thanks for writing about Regex. It save my time alot.

    Reply
  3. Fakharuddin says

    June 28, 2016 at 10:14 am

    Hello Andy,
    Thanks for introducing with the Search Regex, Currently using the Google Search Bar in most of my blog, but going to try this.

    Reply
  4. Adam says

    September 22, 2016 at 4:38 pm

    Visual Composer is a massive headache, 3000 post site previously using it leaves alot of crap to clean up. Would be great to find a a post to ragex all visual composer short codes to foundation equivalent shortcodes.

    Reply
    • Andy Forsberg says

      November 17, 2016 at 9:47 pm

      Seriously! Yes that would be a very helpful tool, but also a ton of work to not only develop initially but also to maintain.

      Reply
  5. PAYFAZZ says

    December 21, 2017 at 1:01 am

    Ah, very useful indeed. I also found this user guide on the WordPress forum. Maybe this can help other users who used this plugin too!
    Wordpress.org/support/topic/additional-usage-notes

    Reply

Leave a Reply Cancel reply

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

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

Primary Sidebar




GET OUR NEWSLETTER


200+ Digital Marketing Tools for Fueling Your Growth

  • Home
  • Contact
  • Advertising
  • Affiliate Disclaimer
  • Privacy Policy



© 2019 Penguin Initiatives.

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.ACCEPT COOKIEPrivacy Policy