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:

/(?:^|\W)amzn_assoc_placement\s*=\s*[\'”][\w\-]+[\'”]/

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

Leave a Reply