Remove all characters from a URL except domain and extensions

waldoctg

New Member
Joined
Jan 4, 2016
Messages
8
This is perfect

Also, can you make one for me to just get rid of any http://; https://; www.; http://www.; https://www.; as well as "/" at the end? Like shown in the example below.

http://bob.woohoo.com bob.woohoo.com
www.bob.woohoo.com/ bob.woohoo.com/
http://www.bill.woohoo.com bill.woohoo.com
https://www.bill.woohoo.com/folder1 bill.woohoo.com/folder1
http://bill.woohoo.com/folder1/ bill.woohoo.com/folder1
https://www.bill.woohoo.com/folder1/folder2 bill.woohoo.com/folder1/folder2
http://www.bill.woohoo.com/folder1/folder2/ bill.woohoo.com/folder1/folder2
http://bill.woohoo.com bill.woohoo.com
www.bill.woohoo.com bill.woohoo.com
bill.woohoo.com bill.woohoo.com
State Information/U.S. Department of Housing and Urban Development (HUD) portal.hud.gov/hudportal/HUD/states
https://mapquest.com/ mapquest.com/
Reference Desk historymatters.gmu.edu/browse/refdesk
https://blast.ncbi.nlm.nih.gov/ blast.ncbi.nlm.nih.gov
http://www.tfl.gov.uk/modalpages/2605.aspx tfl.gov.uk/modalpages/2605.aspx
Marketing Seminars & Webinars | Constant Contact Events constantcontact.com/features/tours.jsp


Moderator edit: Moved from this post to start a new thread.
 
Last edited by a moderator:

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
Hi
Try to test with a udf-function, please
Code:
Public Function GetUrlPart(ByVal this As String) As String
    Dim pReg As Object, needed As String
    Set pReg = CreateObject("VBScript.RegExp")
    pReg.IgnoreCase = True
    pReg.Pattern = "(?:https?\://)?(?:www\.)?(.+)"
    needed = pReg.Execute(this)(0).SubMatches(0)
    GetUrlPart = IIf(Right$(needed, 1) = "/", Left$(needed, Len(needed) - 1), needed)
End Function
Regard,
 
Upvote 0
Hi thanks.

I'm looking for something more I just put in the cell, not necessarily VBA code. Rick Rothstein gave me some good help and I was hoping to have him respond, but then a mod moved my discussion to an entirely new form.

Here's the table I had:


[TABLE="class: t1"]
<tbody>[TR]
[TD="class: td1"]http://bob.woohoo.com[/TD]
[TD="class: td1"]bob.woohoo.com[/TD]
[/TR]
[TR]
[TD="class: td1"]www.bob.woohoo.com/[/TD]
[TD="class: td1"]bob.woohoo.com[/TD]
[/TR]
[TR]
[TD="class: td1"]http://www.bill.woohoo.com[/TD]
[TD="class: td1"]bill.woohoo.com[/TD]
[/TR]
[TR]
[TD="class: td1"]https://www.bill.woohoo.com/folder1[/TD]
[TD="class: td1"]bill.woohoo.com/folder1[/TD]
[/TR]
[TR]
[TD="class: td1"]http://bill.woohoo.com/folder1/[/TD]
[TD="class: td1"]bill.woohoo.com/folder1[/TD]
[/TR]
[TR]
[TD="class: td1"]http://www.bill.woohoo.com/folder1/folder2[/TD]
[TD="class: td1"]bill.woohoo.com/folder1/folder2[/TD]
[/TR]
[TR]
[TD="class: td1"]http://www.bill.woohoo.com/folder1/folder2/[/TD]
[TD="class: td1"]bill.woohoo.com/folder1/folder2[/TD]
[/TR]
[TR]
[TD="class: td1"]http://bill.woohoo.com[/TD]
[TD="class: td1"]bill.woohoo.com[/TD]
[/TR]
[TR]
[TD="class: td1"]www.bill.woohoo.com[/TD]
[TD="class: td1"]bill.woohoo.com[/TD]
[/TR]
[TR]
[TD="class: td1"]bill.woohoo.com[/TD]
[TD="class: td1"]bill.woohoo.com[/TD]
[/TR]
[TR]
[TD="class: td1"]http://portal.hud.gov/hudportal/HUD/states[/TD]
[TD="class: td1"]portal.hud.gov/hudportal/HUD/states[/TD]
[/TR]
[TR]
[TD="class: td1"]http://mapquest.com/[/TD]
[TD="class: td1"]mapquest.com[/TD]
[/TR]
[TR]
[TD="class: td1"]http://historymatters.gmu.edu/browse/refdesk/[/TD]
[TD="class: td1"]historymatters.gmu.edu/browse/refdesk[/TD]
[/TR]
[TR]
[TD="class: td1"]http://blast.ncbi.nlm.nih.gov/[/TD]
[TD="class: td1"]blast.ncbi.nlm.nih.gov[/TD]
[/TR]
[TR]
[TD="class: td1"]http://www.tfl.gov.uk/modalpages/2605.aspx[/TD]
[TD="class: td1"]tfl.gov.uk/modalpages/2605.aspx[/TD]
[/TR]
[TR]
[TD="class: td1"]http://www.constantcontact.com/features/tours.jsp[/TD]
[TD="class: td1"]constantcontact.com/features/tours.jsp

[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,107
Members
452,302
Latest member
TaMere

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