Regex_replace doesn't allow multiple replacements using global flag

I’m on the Business plan and I’ve created a Transform Rule to remove certain query string parameters using the Dynamic Query Rewrite Rule.

regex_replace(http.request.uri.query, "(utm_campaign|utm_source|utm_medium|utm_content)=.*?(&|$)", "")

This should replace all occurances of the querystring parameters utm_campaign, utm_source or utm_content while leaving any other querystring parameters intact.

Here is an example of this expression working:

However it seems Cloudflare implements regex without the /g global modifier so it only replaces the first occurance of one of these parameters.

How do I pass modifier flags to these regular expressions so that my expression will make multiple replacements rather than just one?

Good question, and I’ve not seen this mentioned before. I suggest you open a ticket and post the # here. As you’re in a Business plan, you should get a response pretty quickly. If not, we can put it in the escalation queue.

Thanks, the support ticket is already open here: 2230194
They actually suggested I go to the Community though!
If you’re able to escalate that ticket further I’d appreciate it.

1 Like

Quite often it can be taken care of here, but if you receive an bot reply on that ticket, reply to that and let them know it still doesn’t work. I’ll also put this post in the escalation queue.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.