How to Extract a String from a URL and Replace % with Space?

502 views Asked by At

I am trying to find a way to extract text from a string in Google Data Studio:

Sample Pagename:

https://xx.site.com/group/analytics/search?param=department%20of%20army

I want to strip out:

department%20of%20arm

and have it be:

department of army

The search string could be many different things and many different lengths but the below will always be the same:

https://xx.site.com/group/analytics/search?param=
1

There are 1 answers

0
Nimantha On

The RegEx Calculated Field below first uses the REGEXP_EXTRACT function to capture all characters after ?param= and then incorporates the REGEXP_REPLACE function to remove % followed by any digits \\d+ and replaces it with a (space):

REGEXP_REPLACE(REGEXP_EXTRACT(Field, "\\?param=(.*)$"), "(%\\d+)", " ") 

Google Data Studio Report and a GIF to elaborate: