Keyword replacement remove querystring


(Jamie Smith) #1

Hello. I'm trying to use Matrix keyword replacements/modifiers to get the URL without query string. Just checking whether it can be done.

 

My attempt...

%globals_server_request_uri^replace:[\?(.*)]:%

...removes the question mark but, alas, not the proceeding characters too.

 

I'm in Matrix 4.14.1.

 

Many thanks in advance.

 

Jamie


(Bart Banda) #2

If you are simply trying to get the URL, you should just be able to use %globals_asset_url% 


(David Schoen) #3

Your regex is currently describing a character class that finds a literal "?", "(", "." or ")" (because it's in square brackets "[...]" which means a character class).

 

Instead you want a literal question mark ("\?") followed by any character (".") zero or more times ("*"), or:

%globals_server_request_uri^replace:\?.*:%

but if %globals_asset_url% serves the right purpose it is generally better to avoid regex if you can help it :)