Remove anything after the 3rd / and append some data

mvrht

New Member
Joined
Dec 9, 2017
Messages
18
We have various urls posted into our sheet that sometimes are not valid urls for what we need. So we need to strip some data from it and append some data to the end.

EXAMPLE
Code:
https://www.myurl.com/p/Bce6o9tg0XZ/?utm_source=google&utm_medium=cpc
needs stripping to
Code:
https://www.myurl.com/p/Bce6o9tg0XZ/
and then appending with
refer/?size=web

Leaving me with
Code:
https://www.myurl.com/p/Bce6o9tg0XZ/refer/?size=web
Ideally this needs doing on the fly, so when an invalid url is entered. The function converts it and adds the part on the end, so perhaps I can apply a function to the column or within Google App Script using Javascript

I have had a tinker with the functions here which only deal with the extraction part but no joy yet
https://stackoverflow.com/questions/20717566/excel-remove-everything-after-in-a-url
 
Last edited by a moderator:
Last edited:
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Upvote 0
Confused.
In post #1 you ask to delete everything after the 3rd forward slash.
However, your example in post #1 shows after 5 slashes. I guess you don't count the double slash at the beginning.
What is the result of Post #6 ?
 
Upvote 0

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top