Results 1 to 6 of 6

Extract String From Between 2 Values

  1. #1
    kathleencampbell is offline Novice
    Windows 2K Access 2003
    Join Date
    Mar 2012
    Posts
    6

    Extract String From Between 2 Values

    How do I extract the string of characters that fall between the tags <text> and </text>. The two tags can occur multiple times in one field, with various lengths of text before, between and after them.

    Thank you in advance. I'm stumped.

  2. #2
    June7's Avatar
    June7 is online now Moderator
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    29,623
    You just want to remove the <text> and </text> tags and leave a space in their place?
    Try:
    x = strValue
    Trim(Replace(Replace(x,"<text>"," "),"</text>"," "))

    x can be reference to a field.

    The expression can be used in a query or textbox. If you want the edit to be permanently saved, use the expression in the UPDATE TO row of update query under the field need to populate with the edit.
    Last edited by June7; 03-22-2012 at 01:09 PM.
    To provide db: Make copy, remove confidential data, run compact & repair, zip if large - 2mb allowed, attach to post. Attachment Manager is below the Advanced post editor window.
    If suggestion in this post resolves your issue, please use the Thread Tools and mark the thread as Solved!

    Debug!Debug!Debug! http://www.cpearson.com/excel/debug.htm

  3. #3
    Bob Fitz is offline MS Community Contributor
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    1,343
    If you want to return only the text between the two tags and where there could be multiple instances of those tags in each block of text, then this could be done with a user defined function. The attached db has an example of such a function. If you have any further questions, post back.
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
    Not everyone can access an accdb, you may reach a broader audience by attaching in mdb format.

    Bob Fitzpatrick

    I have never failed. I have found a thousand ways that do not work!

    Microsoft Community Contributor Award (2011)



  4. #4
    kathleencampbell is offline Novice
    Windows 2K Access 2003
    Join Date
    Mar 2012
    Posts
    6
    Thank you for the working example, Mr. Fitzpatrick. This is indeed a wonderful learning moment for me.

  5. #5
    Bob Fitz is offline MS Community Contributor
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    1,343
    Does it actually fulfil your needs?
    If this helped, please click the star at the bottom left of this posting and add to my reputation. Many thanks.
    Not everyone can access an accdb, you may reach a broader audience by attaching in mdb format.

    Bob Fitzpatrick

    I have never failed. I have found a thousand ways that do not work!

    Microsoft Community Contributor Award (2011)



  6. #6
    kathleencampbell is offline Novice
    Windows 2K Access 2003
    Join Date
    Mar 2012
    Posts
    6
    Yes. It is a perfect fit!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. extract something from a field
    By tozey in forum Queries
    Replies: 4
    Last Post: 02-24-2012, 06:54 AM
  2. Extract certain values from field
    By tylerg11 in forum Programming
    Replies: 19
    Last Post: 09-23-2011, 02:27 PM
  3. Convert Number to String in .csv extract
    By CindyR19 in forum Import/Export Data
    Replies: 3
    Last Post: 08-17-2011, 01:58 PM
  4. Combining values of 2 columns into one string
    By LAazsx in forum Programming
    Replies: 1
    Last Post: 11-25-2010, 06:36 PM
  5. Extract numbers from text string strored in a field.
    By khabdullah in forum Programming
    Replies: 2
    Last Post: 12-23-2007, 04:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Tech Forums: Microsoft Office Forums