Results 1 to 6 of 6
  1. #1
    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 offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    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 02:09 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    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.
    Bob Fitzpatrick

  4. #4
    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's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,530
    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.
    Bob Fitzpatrick

  6. #6
    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, 08:54 AM
  2. Extract certain values from field
    By tylerg11 in forum Programming
    Replies: 19
    Last Post: 09-23-2011, 03:27 PM
  3. Convert Number to String in .csv extract
    By CindyR19 in forum Import/Export Data
    Replies: 3
    Last Post: 08-17-2011, 02:58 PM
  4. Combining values of 2 columns into one string
    By LAazsx in forum Programming
    Replies: 1
    Last Post: 11-25-2010, 08:36 PM
  5. Extract numbers from text string strored in a field.
    By khabdullah in forum Programming
    Replies: 2
    Last Post: 12-23-2007, 06: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
  •  
Other Forums: Microsoft Office Forums