querystring.regfilter

STRINGquerystring.regfilterSTRINGurlSTRINGpattern

Available inall subroutines.

Returns the given URL without the parameters matching a regular expression. Groups within the regular expression are treated as if they were written as non-capturing groups. For example:

if (req.url.qs ~ "key-(?:[0-9]|\w)=(.*)-(.*)") { # captures to re.group.1 and re.group.2
set req.url = querystring.regfilter(req.url, "key-([0-9]|\w)"); # does not capture
set req.http.X-Key-1 = re.group.1;
set req.http.X-Key-2 = re.group.2;
}

The "key-([0-9]|\w)" pattern shown here behaves as if it were written as a non-capturing group, "key-(?:[0-9]|\w)", ensuring the contents of re.group.1 and re.group.2 are not affected by the call to querystring.regfilter.

Example

set req.url = querystring.regfilter(req.url, "utm_.*");

User contributed notes

BETA

Do you see an error in this page? Do you have an interesting use case, example or edge case people should know about? Share your knowledge and help people who are reading this page! (Comments are moderated; for support, please contact Fastly support)