I'm looking to extract get variable values from URLs inside of varnish. The get variable in question is named "source" and may or may not be an array. I would like to take the value(s) of source and comma separate them. Putting the URLs through my desired regex would yield the following:
I have created the regex that matches each of those cases appropriately, though I have little experience with capture groups for the purpose of replacement. Here is what I have constructed:
((\?|\&)source(\[])?=(?P<sources>[^&]+))+
Visualization: https://www.debuggex.com/i/_2ib6j-6VKTWE_vV.png
Since varnish has really limited functionalities (no array manipulation, loops, ...), a way to do this is to apply two regexes: