Forum Academy Marketplace Showcase Pricing Features

Regex pattern to remove URL parameters/UTM

Hi all,

I need some help finding and removing any page path/UTM/querystrings from URLs using a Regex pattern.

For example, if a user visits using https://yourdomain.com/facebookpixelid?appid=test I’d like to remove that dynamic data after https://yourdomain.com including the first ‘/’ so that we just get the root domain with https:// and nothing after that.

Any idea the Regex to do so? @NigelG is this something you know about?

Thanks
Reece

1 Like

Thanks Nigel, so is it just the ^(?:https?://)?(?:[^@/\n][email protected])?(?:www.)?([^:/?\n]+) in the Regular Expression input that I copy paste into Bubble? This is well beyond my knowledge here…

1 Like

Yes, that is correct.

1 Like

Thank you!

Regex Nigel!

I’m trying to do the opposite of this and cannot seem to figure it out.

I’m trying to get everything AFTER http://www. or https://www

I mean, it works on regex101, but its got a non-matching and a matching group, and I’m not sure how to make it work in bubble.

It is returning the whole string in bubble.

(?:^http.*://www.)(.+)

Keep it simple: You desire to remove the protocol identifier, which is everything from the start thru “//”. Find that and replace it:

Yields:

image

Now it doesn’t matter if the protocol is http://, https://, ftp://, some_other_protocol_nobody_uses://, etc.

2 Likes

thanks keith!

1 Like

Hey all - I wanted the following and @NigelG kindly helped me out in a private message. I wanted to share for all.

Goal = Extract the query string but keep more than just the root domain

Example: https://www.imdb.com/title/tt5491994/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=12230b0e-0e00-43ed-9e59-8d5353703cce&pf_rd_r=68MZSCC1NRKFNE55V64M&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=toptv&ref_=chttvtp_tt_1

Desired output: https://www.imdb.com/title/tt5491994/

Required regex = ^[^?]+

I realized what I actually needed to do was throw away everything from the “?” on. I managed that with a regex find and replace as follows:

Find: ?(.*)
Replace: [nothing]

2 Likes

This may be helpful to others.

1 Like