My goal is to \"whitelist\" certain querystring attributes and their values so varnish will not vary cache between the urls.
Example:
Url 1: http:/
You want to strip out utm_code but it's not covered by either of the regexps you are using.
Try this:
# Strip out specific utm_ values from request URL query parameters
set req.url = regsuball(req.url, "([\?|&])utm_(campaign|content|medium|source|term|code)=[^&\s]*&?", "\1");
# get rid of trailing & or ?
set req.url = regsuball(req.url, "[\?|&]+$", "");
Or if you want to strip all URL parameters that start with utm_ you can go with:
# Strip out ALL utm_ values from request URL query parameters
set req.url = regsuball(req.url, "([\?|&])utm_(\w+)=[^&\s]*&?", "\1");
# get rid of trailing & or ?
set req.url = regsuball(req.url, "[\?|&]+$", "");