I am trying to convert 'http://city.example.com' to 'http://www.example.com/city' in an Excel sheet.
I have tried a multi-step approach to first TRIM or SUBSTITUTE the prefix then the suffix, but I'm in over my head.
Any help would be greatly appreciated. Thanks in advance!
Do heed the comment regarding formulating a proper question and posting what you've tried and what is going wrong.
Either way, assuming your domains are in column A and there is only a single subdomain:
=SUBSTITUTE(A1,MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2)),"www")&MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2))
Breaking it down into pieces:
FIND("//",A1,1)+2 will return the index of the start of the subdomain.
FIND(".",A1,1) will return the index of the first period, the end of the subdomain.
As such, the string from the start of the subdomain to the period will be the subdomain - since we're getting index's back we have to subtract them to get our MID length - FIND(".",A1,1)-(FIND("//",A1,1)+2)
Chaining those together, we can say we want to substitute whatever is from the // to the first period with www. - SUBSTITUTE(A1,MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2)),"www")
This now leaves us with the subdomain replaced with www, so we just need to append the subdomain now, which we already know how to get - it's the mid formula we just used:
MID(A1,FIND("//",A1,1)+2,FIND(".",A1,1)-(FIND("//",A1,1)+2)
As such, we concatenate our two formulas together to get the result.
Related
I have an excel file with 1000 sites URL in a column.
I want to filter rows based on occurrence of forward slash.
Here I want to filter a site names where forward slash (/) occurrence is only 5.
So result would be
Https://test.sharepoint.com/it/basedonhistory/kite
Https://test.sharepoint.com/it/basedonhistory/kite1
Https://test.sharepoint.com/it/basedonhistory/kite2
Thank you in advance for you help.
Here is one possibility, if one doesnt have o365.
=IFERROR(INDEX($A$1:$A$4,AGGREGATE(15,6,ROW($A$1:$A$4)/((LEN($A$1:$A$4)-LEN(SUBSTITUTE($A$1:$A$4,"/","")))=5),ROW(A1))),"-")
Good afternoon,
I am not really an Excel champion so I am having a bit of headache with the last assignment my teacher gave me as I have to use three functions at the same time.
Basically I have to extract the urls from B2 and below and be just "www.cocacola.es" in K2 (just ignore column D and E): https://ibb.co/2S36cC0
I was kinda ok at this point: =MID(B2,FIND("/",B2)+2,LARGO(B2))
Then I got a little bit lost.
I had a look at the forum as well and I actually ended up finding a solution by adding -FIND("/",B3)-32)) at the end of the function but it only works for few rows: https://ibb.co/1n0ty8y
I guess it is something related to LEN but I can't figure how to fix it.
Sorry for the dumb question but it's my last work and I really wanna understand it.
It appears that you want the sub-string between the second / and the third /.
For all your examples the second / is in the eighth position. So we can use:
=MID(MID(A1,9,99),1,FIND("/",MID(A1,9,99))-1)
with the full url in A1.
I have a bunch of URLs in a column like below:
https://www.example.com/xx/yy/product-name-could-be-30238543/
https://www.example.com/xx/yy/product-name-might-70293274/
https://www.example.com/xx/yy/product-name-may-40242653/
I wish to extract the ID's from the id but not with the last / in them. The right function gives me below:
40242653/ but i wish to get rid of the ID's too within the same function so can someone suggest a way?
Otherwise, i have to use another replace function separately to get rid of ending trailing slashes.
Thanks,
If all the IDs have 8 numerals, then you can use:
=LEFT(RIGHT(A1,9),8)
If they have more or less than 8 numerals, then ignore this answer.
I have found this to be easier to use (It extracts everything after the last occurrence of - in them.
SUBSTITUTE(RIGHT(A1;LEN(A1)-FIND("#";SUBSTITUTE(A1;"-";"#";(LEN(A1)-LEN(SUBSTITUTE(A1;"-";"")))/LEN("\"))));"/";"";1)
Ive got a list of urls, Im trying to check if for each cell the the url contains .com OR .co.uk and if it does put the text TRUE into the result cell, this way i can filter the result column to find all the cells that contain .com or .co.uk as the top level domain of the url.
At the moment im trying to use
=IF(D2=".com","TRUE", "FALSE")
The issue Im having is to do with the first argument to check if the url contains .com OR .co.uk, at the moment its just checking if the whole url == .com.
You can use FIND:
=OR(ISNUMBER(FIND(".com",A1)),ISNUMBER(FIND(".co.uk",A1)))
Use ISNUMBER to swallow any #VALUE! errors.
Note that FIND does a case-sensitive search. For a case-insensitive search, use SEARCH instead.
You could also use regexextract with an or "|" to give it both variations:
=if(isna(REGEXEXTRACT(A1,"\.com|\.co\.uk")),,true)
I have an Excel document with a column that contains cells of text (small paragraphs usually). I'd like to find a way (preferably a formula) to extract any url's those cells by row and add them to another column.
I've been messing around with MID and FIND quite a bit and can very easily get to the begginning of those URLs by searching for "http", but I can't figure out how to then find the length of the url so I can grab it.
Really looking forward to any help anyone could offer. It's driving me nuts!
To take into account the URL happening at the end of a string you'll need to add some error handling.
This should work for both mid string and end of string:
=MID(C11,FIND("http",C11),IFERROR(FIND(" ",C11,FIND("http",C11))-1,LEN(C11))-FIND("http",C11)+1)
Ok, I think I've got it working. Check it out:
=MID(C11,FIND("http",C11),(FIND(" ",C11,FIND("http",C11))-FIND("http",C11))-4)
Once you've identified the start position of the URL look for the first space after that, should be the end of the URL.
Your most likely option is to make sure you can rely on the URLs being formed the same way. Like, always start with "http" and always end with "/" or a ".com". Then you can do formulas to find the index start, index end, and grab the MID for everything in between.
It should look like this:
=FIND("http",D3)
returns the location of the first part.
=FIND(".com",D3)
returns the location of the end
=MID(D3,D9,D10-D9+4)
Returns the string provided by the start to the end+4 (to allow for those 4 characters)