WP Engine

Solutions
AgencyEnterpriseSmall & Medium BusinessMarketer
How WP Engine supports marketers.Benefits for marketers.Features that help you innovate.
Developer
How WP Engine supports developers.Benefits for developers.Features that help you move faster.
Explore Our Platform
Insights
Thought LeadershipTopics

Read articles, trends, and insights on these topics from leaders in marketing and technology.

Creative AgilityEnterprise PerformanceActionable IntelligenceEcosystem Integration
Resources

Access ebooks, whitepapers, webinars, and other knowledge from our ecosystem of digital experts.
Visit Resource Center.

Delivering a Slam Dunk Experience on WordPressEbook: The Ultimate Guide to WordPress Plugins15 Common WordPress Mistakes Agencies and their Clients Make
Case Studies
About
Our CompanyOur PlatformLatest News

Access the latest news from inside WP Engine.
Visit the Newsroom.

WP Engine Secures Strategic Growth Investment From Silver LakeWP Engine Unveils First WordPress Digital ExperienceWP Engine Expands Global Presence with New Office in Brisbane
Media Center

Get announcements and resources about WP Engine.

Press Releases
Careers at WP Engine
Pricing
Sales Questions?

Contact Sales

Discover why organizations of all types and sizes choose WP Engine — and how it can benefit you.

Chat

1

I'm available right now to answer any of your questions!

Reply

Call

+1-512-201-4819

Contact

Send a message

Compare Plans
Need Support?
Support DocumentationBilling HelpSupport

We offer support 24 hours a day, 7 days a week, 365 days a year. Log in to get expert one-on-one help.

Log in for support

Sales Questions

Contact Sales

Discover why organizations of all types and sizes choose WP Engine — and how it can benefit you.

Chat

1

I'm available right now to answer any of your questions!

Reply

Call

+1-512-201-4819

Contact

Send a message

Sign in
Sign in
Search

Search

Compare Plans
Call Sales +1-512-201-4819
Menu
AgencyEnterpriseSmall & Medium BusinessMarketers
How WP Engine supports marketers.Benefits for marketersFeatures that help you innovate.
Developers
How WP Engine supports developers.Benefits for developers.Features that help you move faster.
Our PlatformPricingResource CenterOur CompanySolution CenterThought LeadershipDocumentationCareers

Advanced Feature- HTML Regex Replacements

Austin Gunter 2.27.2012

We recently rolled out a really awesome feature set for advanced WordPress Users.  If you’re a WordPress badass, you are probably going to love this new tool.

Inside the WP Engine admin screen, scroll to the bottom and you’ll see the “Advanced Configuration” section.  We’re going to be adding more tools here, but for now we’ll focus on the HTML Regex Replacements Tool.  This first advanced config feature is a very precise “search and replace” tool that gives you the power to change the HTML that WP creates.  The tool will behave similarly to preg_replace().

WordPress Advanced Configuration HTML Regex Replacement tool

Example: The following example removes all HTML comments in the first pattern, and causes a favicon (with any filename extension) to be loaded from another domain in the second pattern.

#<!--.*?-->#s =>
#bsrc="/(favicon..*)"# => src="http://mycdn.somewhere.com/$1"

You can specify any number of regular expressions to match HTML content and the replacement value.  The replacement can also include grouping replacements.

Among other things, this allows you to:

  1. Add support for the CDN where our normal CDN patterns don’t find it, by matching the paths in question and inserting the correct CDN URL in front of them.
  2. Remove bad code, like if they’re including jQuery in the footer as well as the header and with the wrong version.
  3. Change a wrong url, by finding it and replacing with the right one.
  4. Add optimizations like replacing a WordPress jQuery URL with the Google hosting one.

Like I mentioned, the replacement tool is essentially a search and replace tool, but it works at a very tactical level.  Stating the obvious, playing with your code this tactically can get complicated.  This feature is not for everyone to jump into right away.  If you’re a badass, go for it.  If not, just coordinate with support.  They’ll take care of you.  And remember, you can create a restore point before you start making changes.  So if things get buggy, you can just ctrl + z your WordPress back to the way it was.

We will continue adding advanced features to this section, making it possible for technical consultants (as well as our tech support) to do all sorts of useful things without resorting to special “tech support tools” or configuration files.

Oh, and while I’m on the subject….is there a feature you’d like to see added here?  If you’re one of the consultants who has thought “wow, I wish that they would build a tool that…..” please tell us.  If it’s a useful tool for lots of WP Engine customers, we may be able to build it!

 

More WordPress news from WP Engine

WordPress Consultant Profile: Rachel BakerQuick and dirty developer fix: Going Line-By-Line

Comments

  1. Tim says

    May 2, 2012 at 7:37 pm

    Does this find/replace cause a permanent change.. or are the changes just made on the fly to the rendered/served page?

    Reply

Leave a Reply Cancel reply

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

  • Subscribe

    Subscribe to our blog to get great tips for your WordPress site.

  • Favorite Tweets by @wpengine
  • Sign In

    Solutions

    • Agency
    • Enterprise
    • SMB
    • Marketer
    • Developer

    Insights

    • Blog
    • Torque
    • Velocitize

    About

    • Our Company
    • Leadership Team
    • Our Platform
    • Careers
    • Affiliates
    • Contact
    • Legal
    • Newsroom
    • Privacy Policy

    Resources

    • Resource Center
    • Documentation
    • Solution Center
    • Find an Agency

    WP Engine

    504 Lavaca Street, Suite 1000
    Austin, TX 78701

    Sales

    +1-512-201-4819
    [email protected]
    7am–7pm CST

    Billing

    [email protected]

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Instagram
    • RSS
    © 2013—2026 WPEngine, Inc. All rights reserved.
    WP ENGINE®, VELOCITIZE®, TORQUE®, EVERCACHE®, and the cog logo service marks are owned by WPEngine, Inc.