简体   繁体   中英

Extract URL's from a Cell of Text in Excel

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)

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)

一旦您确定了URL的起始位置,请查找之后的第一个空格,应该是URL的结尾。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM