Skip to content

Instantly share code, notes, and snippets.

@robhammond
Created March 2, 2018 14:47
Show Gist options
  • Save robhammond/a171d67ea4e36a2af5afbb560a3eba40 to your computer and use it in GitHub Desktop.
Save robhammond/a171d67ea4e36a2af5afbb560a3eba40 to your computer and use it in GitHub Desktop.
Create a regular expression to identify evergreen content in Google Analytics
#!/usr/bin/env perl
use Modern::Perl;
use DateTime;
my $past = DateTime->now->subtract(months => 6);
my $past_year = $past->year();
my $past_month = $past->month();
my $past_2_year = $past->subtract(years => 1)->format_cldr('yy');
my $y_str;
for my $y (@{[0..$past_2_year]}) {
$y_str .= sprintf("%02d", $y) . "|";
}
chop $y_str;
local $" = "|";
say "^(20($y_str)-[0-9]+|$past_year-0?(@{[1..$past_month]}))-[0-9]+\$";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment