+ Reply to Thread
Results 1 to 9 of 9

Parsing URLs

  1. #1
    Registered User
    Join Date
    11-23-2015
    Location
    Oxford, England
    MS-Off Ver
    2010
    Posts
    54

    Parsing URLs

    Hi
    I have a long list of URLs that I need to split. I know that I can do this and separate the domain, but what I actually want to do is to split the first two levels of the URL from the remainder, apols if I am not using the right terminology. So for example:-

    full URL http://share.mycompany.com/path-name.../date/document name.ext

    split into:-

    First two levels http://share.mycompany.com/path-name
    and
    remainder /workspace/date/document name.ext or workspace/date/document name.ext

    Is that possible?

    Any help would be gratefully received, thanks in advance.

  2. #2
    Registered User
    Join Date
    11-23-2015
    Location
    Oxford, England
    MS-Off Ver
    2010
    Posts
    54

    Re: Parsing URLs

    Also should have said, the URLs may not be the same length, some may just be the two levels that I need, but some may have several more levels. Some may have a document name, but others may not, etc, etc

  3. #3
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: Parsing URLs

    If you post a few examples of where the split wants to take place, preferably in a spreadsheet, it will be easier to provide an answer

  4. #4
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: Parsing URLs

    As an option you could split each url by "/" and then concatenate new url with one level.

  5. #5
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Parsing URLs

    For the first two levels, use this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    If you don't want the final '/' included then add '-1' at the end, like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    For everything after that, use this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    That won't include the '/' before - if you want the '/' included, then add '+1' at the end:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Hope that does what you want.

    Edit: the above work by finding the fourth instance of the '/' character, so if you have a share address which doesn't start with 'http://share.' but directly with 'share.' then change the '4' in the above formulae to '2' instead.
    Last edited by Aardigspook; 12-16-2016 at 10:49 AM. Reason: Add note about possible amendment
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  6. #6
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: Parsing URLs

    Possibly
    =LEFT(A1,FIND("@",SUBSTITUTE(A1,"/","@",4)))
    ==MID(A1,FIND("@",SUBSTITUTE(A1,"/","@",4)),99)

    but more detail would be better

  7. #7
    Registered User
    Join Date
    11-23-2015
    Location
    Oxford, England
    MS-Off Ver
    2010
    Posts
    54

    Re: Parsing URLs

    Thanks Aardigspook, that worked an absolute treat! Made my day! Really grateful and appreciative of such swift responses from everyone too.

  8. #8
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Parsing URLs

    You're welcome. Thanks for the feedback and the rep.

    One point: if your url contains the character '#' already, then the formulae above might fail (depending on exactly where the '#' is). To get round this, you can replace the '#' with 'CHAR(160)' which is a blank space and therefore won't be in any url. Just select the formulae and do a find-and-replace of '#' with 'CHAR(160)' (without the inverted commas). I meant to change the formulae before I posted them earlier, but didn't - sorry!

  9. #9
    Registered User
    Join Date
    11-23-2015
    Location
    Oxford, England
    MS-Off Ver
    2010
    Posts
    54

    Re: Parsing URLs

    Thanks, so far there are no # characters in the file, but I will amend that to the CHAR(160) as you suggest just in case there should be in the future!

    Thanks again, really grateful :-)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help Regarding Trimming of the URLs
    By david106 in forum Excel General
    Replies: 2
    Last Post: 09-01-2016, 09:26 PM
  2. Grab URLs on a Website
    By gautum123 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-22-2015, 12:58 PM
  3. Run the same macro for 30 urls
    By Hagea_Dan in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 08-15-2014, 02:00 PM
  4. Get final urls
    By jimbo222 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2011, 06:55 PM
  5. Converting text URLs to hyperlinked URLs
    By ranchhand in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-25-2011, 01:46 PM
  6. using web query and javascript urls
    By francisos in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-20-2008, 08:42 PM
  7. checking urls in excel?
    By tiempo67 in forum Excel General
    Replies: 0
    Last Post: 02-25-2005, 05:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1