+ Reply to Thread
Results 1 to 9 of 9

Trying to find how to dynamically parse out text using delimiters.

  1. #1
    Registered User
    Join Date
    05-16-2016
    Location
    Mountain View, USA
    MS-Off Ver
    2015
    Posts
    6

    Trying to find how to dynamically parse out text using delimiters.

    Hi there,

    I am looking to parse out text from a data string, example below:

    AX_TEST_EXAMPLE_XYZ [13141-14141-14]

    Using LEFT I can get the first two letters and using RIGHT I can get the final string between the [], I used MID to get the TEST text by using the FIND function. Now I am stuck, as I need the text between each "_".

    Is there a way to define the first, second and third "_" in the MID formula?

    Thanks

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,840

    Re: Trying to find how to dynamically parse out text using delimiters.

    It sounds like you are somewhat familiar with the FIND() function, but perhaps you are unaware of the optional 3rd argument: https://support.office.com/en-us/art...3-d0d89b0a0628
    After you find the position of the first _, finding the second one should be the same as finding the first, just telling the FIND(() function to start the 2nd search in the position after the 1st _.

    On edit: At the risk of offending the Excel community, if you are not "married" to Excel for this, you could take your data to Google Sheets and use their built in =SPLIT() function to parse the text using _ as the delimiter. Such a spreadsheet would not be cross-compatible with Excel, but it might be easier than trying to nest together the mess of "MID(FIND(MID(...))))" functions that could be needed for this operation in Excel.
    Last edited by MrShorty; 05-17-2016 at 01:01 PM.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    05-16-2016
    Location
    Mountain View, USA
    MS-Off Ver
    2015
    Posts
    6

    Re: Trying to find how to dynamically parse out text using delimiters.

    Hi,

    Thanks for your reply.

    This is really helpful, but where I am having difficulty is that the length of the text is different in each data string, so I cannot use a ubiquitous formula to find the start point of the second delimiter. Example below:

    AX_TEST_EXAMPLE_XYZ [13141-14141-14]
    TZ_TESTING_EXAMPLES_XYZ [13141-14141-14]

  4. #4
    Registered User
    Join Date
    05-16-2016
    Location
    Mountain View, USA
    MS-Off Ver
    2015
    Posts
    6

    Re: Trying to find how to dynamically parse out text using delimiters.

    So I guess if I were to simplify the question, is there a formula that can say, "Find the text between the 2nd and 3rd delimiters"

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,840

    Re: Trying to find how to dynamically parse out text using delimiters.

    I don't understand. It looks to me like it should work just fine. The total length of the string or the length of any substring should not impact the result.
    (In B1) =FIND("_",$A1,1) should return 3
    (In C1)=FIND("_",$A1,B1+1) should return 8
    (In D1) copy of C1 should return 16
    Copy B1:D1 down to B2:D2 and you should get 3, 11, and 20

    A MID() function should then easily extract the text between any two of the delimiters.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Trying to find how to dynamically parse out text using delimiters.

    Try this...

    Data Range
    A
    B
    C
    D
    1
    AX_TEST_EXAMPLE_XYZ [13141-14141-14]
    TEST
    EXAMPLE
    XYZ
    2
    TZ_TESTING_EXAMPLES_XYZ [13141-14141-14]
    TESTING
    EXAMPLES
    XYZ
    3
    ------


    This formula entered in B1:

    =TRIM(MID(SUBSTITUTE(LEFT($A1,FIND("[",$A1)-1),"_",REPT(" ",100)),COLUMNS($B1:B1)*100,100))

    Copy across to D1 then down as needed.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  7. #7
    Registered User
    Join Date
    05-16-2016
    Location
    Mountain View, USA
    MS-Off Ver
    2015
    Posts
    6

    Re: Trying to find how to dynamically parse out text using delimiters.

    That's it!

    Thank you both very much for your help.

    I am fast becoming a huge fan of this forum.

    Until next time, thanks.

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Trying to find how to dynamically parse out text using delimiters.

    You're welcome. Thanks for the feedback!

  9. #9
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,253

    Re: Trying to find how to dynamically parse out text using delimiters.

    Try

    =TRIM(MID(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE($A1,"_"," "),"[",""),"]","")," ",REPT( " ",250)),(COLUMNS($A:A)-1)*250+1,250))

    Text in A1, formula in B1 and drag across columns

+ 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. Replies: 2
    Last Post: 04-09-2014, 11:48 AM
  2. [SOLVED] Find text between two rows dynamically
    By JoTedy in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 12-07-2012, 08:41 PM
  3. VBA splitting Text with Delimiters?
    By Irish RayRay in forum Excel General
    Replies: 6
    Last Post: 03-14-2012, 12:54 PM
  4. Text to Column delimiters
    By sapling in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-20-2010, 04:48 PM
  5. How to dynamically-parse text from webpage to variables?
    By amateurmetheus in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-28-2010, 11:54 AM
  6. Find and parse email address from text string
    By jchamber00 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-28-2009, 11:33 AM
  7. [SOLVED] Parse data with uneven lengths and different delimiters
    By [email protected] in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-06-2006, 04:10 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