0

I want to remove everthing between .com/ to ?utm

How can I do that? I use Notepad++ and Kate.

https://www.forexample.com/cat.belt?utm2900&eav=AfbHJya2K7Mbg2mPWatN
https://www.forexample.com/cat.food?utm89748&eav=AfbHJya2K7Mbg2mPWatN
https://www.forexample.com/dog.necklace?utm25875&eav=AfbHJya2K7Mbg2mPWatN
https://www.forexample.com/dog.belt?utm25285&eav=AfbHJya2K7Mbg2mPWatN
https://www.forexample.com/dog.food?utm785844&eav=AfbHJya2K7Mbg2mPWatN

I tried to Google the solution, but nothing really works.

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563

2 Answers2

2

In that case, you could use (?:^.*?\.com\/)(.*?)(?:\?utm.*$) with $1 matching "cat.belt", "cat.food" etc.

In fact, the only change in comparison to @akash 's answer is that you invert the capturing and non-capturing groups.

Matteo B.
  • 21
  • 4
1

try the pattern: (^.*?\.com\/)(?:.*?)(\?utm.*$)

substitution: $1$2

demo here: https://regex101.com/r/xChAme/2

akash
  • 587
  • 4
  • 16
  • Thank you so much. It works but my question was wrong. I'm sorry for that. I was little hurry. I need to keep everything between two word. cat.belt cat.food dog.necklace I need to keep all this. – Eric Abraham Nov 20 '22 at 13:27