Remove all characters before domain & subdirectory in URL

RD_MG

New Member
Joined
May 11, 2016
Messages
2
Similar to this thread: http://www.mrexcel.com/forum/excel-...-url-except-root-domain-domain-extension.html

I'm looking for a formula within Excel to remove all characters before the domain. Below are a couple of examples as the list will be ever-growing, and will also be paired up with another column to match specific strings of data.


Example URL StringResult
https://www.example.comexample.com
https://example.uk/example.uk/
http://www.example.com/sub123example.com/sub123
http://example.com/sub123/example/example.com/sub123/example/

<tbody>
</tbody>








Ultimately I'm looking to address the different variations of https & http, as well as www and non-www. Plus any variation of country codes, with or without an ending forward slash that doesn't get removed if it is present.

Any help would be greatly appreciated!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Welcome to the forum.

If I read this correctly, your issue is a bit simpler than the other thread. This might work:

AB
1Example URL StringResult
2https://www.example.comexample.com
3https://example.uk/example.uk/
4http://www.example.com/sub123example.com/sub123
5http://example.com/sub123/example/example.com/sub123/example/

<colgroup><col style="width: 25pxpx"><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B2=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"https://",""),"http://",""),"www.","")

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>
 
Upvote 0
Also:
=SUBSTITUTE(MID(A2,FIND("//",A2&"//")+2,2083),"www.","")

I went with 2083 because after a little research, that seems to be the longest URL supported by any browser.
 
Upvote 0
Welcome to the forum.

If I read this correctly, your issue is a bit simpler than the other thread. This might work:

AB
1Example URL StringResult
2https://www.example.comexample.com
3https://example.uk/example.uk/
4http://www.example.com/sub123example.com/sub123
5http://example.com/sub123/example/example.com/sub123/example/

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B2=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A2,"https://",""),"http://",""),"www.","")

<tbody>
</tbody>

<tbody>
</tbody>

Thanks for the warm welcome and I was certainly overthinking things! This worked and I truly appreciate it!

Also:
=SUBSTITUTE(MID(A2,FIND("//",A2&"//")+2,2083),"www.","")

I went with 2083 because after a little research, that seems to be the longest URL supported by any browser.

This worked as well, thanks!
 
Upvote 0

Forum statistics

Threads
1,215,982
Messages
6,128,096
Members
449,419
Latest member
mammothzaa

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