Strip Queries from URLS in Google Data Studio with REGEXP_REPLACE

3k views Asked by At

I'm trying to build a new calculated field in Google Data Studio to get rid of all the queries. I've tried the following formula:

REGEXP_REPLACE(page,"\?(.*)","")

But Data Studio return me an invalid formula... I guess that's because It's not Google RE2. how do I translate this into Google RE2?

1

There are 1 answers

0
Wiktor Stribiżew On BEST ANSWER

You may use

REGEXP_REPLACE(page,"[?].*","")

The pattern will be parsed as a literal ? followed with any 0+ chars, and the whole match will get replaced with an empty string.