As I Solve

Bulletproof solutions for the savvy developer.

Regex to match all _gaq.push function call instances


Potential usage: grep search/replace for a site full of Google Analytics to migrate to Universal Google Analytics.

Matching Regex for all instances of _gaq.push

/_gaq\.push\(\['_[^']*'(,? ?[^,(\]\);)]*){0,4}?]\);/g

Play with it here: regexr.com/38pp5

,

Leave a Reply