+ Reply to Thread
Results 1 to 11 of 11

Extract A String in an URL

  1. #1
    Registered User
    Join Date
    03-03-2015
    Location
    Burnaby, BC
    MS-Off Ver
    2013
    Posts
    14

    Extract A String in an URL

    Hey guy, im stuck on this scenarion.

    I have logs of thousands of entries such as this

    https://seatgeek.com/bands/boston-red-sox?p=1
    https://seatgeek.com/teams/coldplay?p=2
    https://seatgeek.com/bands/katy-perry?p=3
    https://seatgeek.com/teams/new-york-rangers?p=4

    I want to be able to return the band name in the next column.

    I need something that says return string between ".com/" and "?" from a url

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,819

    Re: Extract A String in an URL

    If your data starts in A2 and continues down column A, put this formula in B2:

    =MID(A2,SEARCH(".com/",A2)+5,FIND("?",A2)-SEARCH(".com/",A2)-5)

    and copy down.

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    03-03-2015
    Location
    Burnaby, BC
    MS-Off Ver
    2013
    Posts
    14

    Re: Extract A String in an URL

    Thanks for the reply Pete. The data is in C2 ( I edited the formula) but the value returns a ?Name error

    =MID(C2,SEARCH(".com/",cs)+5,FIND("?",cs)-SEARCH(".com/",cs)-5)

    Whats the +5 -5 all about?

    Any other ideas?

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Extract A String in an URL

    That should be C2 not cs

    =MID(C2,SEARCH(".com/",C2)+5,FIND("?",C2)-SEARCH(".com/",C2)-5)
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  5. #5
    Forum Contributor
    Join Date
    12-13-2013
    Location
    Calgary,AB,Canada
    MS-Off Ver
    2016,O365
    Posts
    236

    Re: Extract A String in an URL

    Hi, Nice to see a neighbor (from Burnaby ,BC) here.

    other option is as follow
    =MID(LEFT(A2,FIND("?",A2)-1),FIND("com/",A2)+4,9999)
    =SUBSTITUTE(SUBSTITUTE(A2,LEFT(A2,FIND("com/",A2)+3),),MID(A2,FIND("?",A2),9999),)


    Quote Originally Posted by CoopertheRescuedog View Post
    Thanks for the reply Pete. The data is in C2 ( I edited the formula) but the value returns a ?Name error

    =MID(C2,SEARCH(".com/",cs)+5,FIND("?",cs)-SEARCH(".com/",cs)-5)

    Whats the +5 -5 all about?

    Any other ideas?

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,819

    Re: Extract A String in an URL

    Quote Originally Posted by CoopertheRescuedog View Post
    Whats the +5 -5 all about?
    As ChemistB has said, it should be C2 in the formula, and not cs.

    SEARCH will return the character number where the match is first found, but you want to extract the data starting at 5 characters beyond the beginning of ".com/", so that explains where the 5 comes from.

    Hope this helps.

    Pete

  7. #7
    Registered User
    Join Date
    03-03-2015
    Location
    Burnaby, BC
    MS-Off Ver
    2013
    Posts
    14

    Re: Extract A String in an URL

    Awesome guys thanks so much, I had to change the 5 to an 11 and a few of the cells i had to change to 13 and -13 but it works! thanks so much!

  8. #8
    Registered User
    Join Date
    03-03-2015
    Location
    Burnaby, BC
    MS-Off Ver
    2013
    Posts
    14

    Re: Extract A String in an URL


  9. #9
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,819

    Re: Extract A String in an URL

    If the URL is in A2, and you have boston-red-sox in B2, you can do this in C2:

    =SUBSTITUTE(A2,B2,"u2")&6

    but it is hard to generalise with only one example of what you want to achieve.

    Hope this helps.

    Pete

  10. #10
    Forum Contributor
    Join Date
    12-13-2013
    Location
    Calgary,AB,Canada
    MS-Off Ver
    2016,O365
    Posts
    236

    Re: Extract A String in an URL

    =SUBSTITUTE(A2,MID(LEFT(A2,FIND("?",A2)-1),FIND("com/",A2)+4,9999),"bands/u")&6
    OR
    =SUBSTITUTE(A2,SUBSTITUTE(SUBSTITUTE(A2,LEFT(A2,FIND("com/",A2)+3),),MID(A2,FIND("?",A2),9999),),"bands/u")&6

  11. #11
    Registered User
    Join Date
    03-03-2015
    Location
    Burnaby, BC
    MS-Off Ver
    2013
    Posts
    14

    Re: Extract A String in an URL

    Thanks guys im getting there

    This is what I need actually:
    https://seatgeek.com/bands/u2/2014/10/08 is actually the syntax I need.

    Here is what I have so far

    https://seatgeek.com/bands/10/21/12?p=1 (from petes formula =SUBSTITUTE(A2,B2,"u2")) I removed the &6

    Caabyyc great formula as well.

    Is this tricky or am I just a newb?

    This is my data set:

    https://seatgeek.com/bands/boston-red-sox?p=1
    https://seatgeek.com/teams/coldplay?p=2
    https://seatgeek.com/bands/katy-perry?p=3
    https://seatgeek.com/teams/new-york-rangers?p=4
    https://seatgeek.com/theater/motown-the-musical?p=5

+ 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. Extract string based on specific string
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-15-2014, 12:16 AM
  2. [SOLVED] Extract all the words from a string for processing, while leaving string intact.
    By staggers47 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-10-2014, 02:02 PM
  3. [SOLVED] How to Extract A Number from String if Text within the String Equals XYZ
    By tyrsfury in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-15-2012, 03:30 PM
  4. [SOLVED] Extract a mainly numeric string (ISSN number) from an arbitrary string
    By Buzzed Aldrin in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 07-04-2012, 01:49 PM
  5. Replies: 16
    Last Post: 10-11-2011, 12:31 PM
  6. Extract small string of text from larger string
    By mark_jam3s in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-23-2010, 05:36 AM
  7. Replies: 1
    Last Post: 08-23-2007, 01:10 PM

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