Regular ExpressionsAccelerator for WordPress

A regular expression is a powerful language to match text content by various patterns.

For an instance, we have the Amazon Advertising script inside our page that we want to delay loading:

amzn_assoc_placement = "adunit0";
amzn_assoc_enable_interest_ads = "true";
amzn_assoc_tracking_id = "baskingridgeh-20";

So, the pattern for detecting this script by its body may be:


Another example – there is separated script:

<script src="/dir/abc.js">

So, we can match it by:

@/abc\.js@ or src:@/abc\.js@ if is needed to limit searching only in src (see below).

Here we can test and debug our patterns and look at the syntax.

Special prefixes for styles and scripts#

In exclusions in styles and scripts we can limit the scope of matching, as body, ID or source URL by adding related prefixes:

  • src

    Matching with content of src attribute.

  • id

    Matching with content of id attribute.

  • body

    Matching with body content. Body is taked as from inline script (or style) as from by URL.

This prefixes can be combined, e.g. src,body or id,src, etc. E.g. src,body:@abc@ will search matching src attribute and body with string abc.

Also, if no prefixes are defined then it means matching in all places. E.g. id,src,body:@abc@ equals to @abc@.

Leave a Reply