Remove UTM links Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Remove UTM links

Post by milkygirl90 » 28 Jul 2021, 22:41

I'd like to clean all URLs that end with &utm_ or ?utm=.

May I understand why the one below doesn't clean?

Thank you.

Code: Select all

https://www.abc.com/corrsym.php?s=DEF&utm_content=buffer746d0&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer

Code: Select all

Clipboard := RegExReplace(Clipboard, "*.com.*\K&&utm_.*") ;Remove all UTM tracking links

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Remove UTM links

Post by Rohwedder » 29 Jul 2021, 00:39

Hallo,
perhaps?:

Code: Select all

ClipBoard = https://www.abc.com/corrsym.php?s=DEF&utm_content=buffer746d0&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer
Loop
	Clipboard := RegExReplace(Clipboard, "\.com.*\K(&utm_|\?utm=)[^&?]*",, Count) ;Remove all UTM tracking links
Until, !Count
MsgBox,% ClipBoard

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: Remove UTM links

Post by milkygirl90 » 29 Jul 2021, 01:34

Hi there,

just thinking aloud - will it be possible to script it without any form of looping?

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Remove UTM links  Topic is solved

Post by Rohwedder » 29 Jul 2021, 02:00

Then:

Code: Select all

ClipBoard = https://www.abc.com/corrsym.php?s=DEF&utm_content=buffer746d0&utm_medium=social&utm_source=facebook.com&utm_campaign=buffer
Clipboard := RegExReplace(Clipboard, "(&utm_|\?utm=)[^&?]*") ;Remove all UTM tracking links
MsgBox,% ClipBoard

User avatar
milkygirl90
Posts: 565
Joined: 10 Nov 2020, 21:22

Re: Remove UTM links

Post by milkygirl90 » 29 Jul 2021, 03:15

edit: managed to get it to work. thank you so much!

Post Reply

Return to “Ask for Help (v1)”