2 Replies Latest reply on May 18, 2011 5:13 PM by lauriehughes

    select text between

    lauriehughes

      Title

      select text between

      Post

      I want to show in a field only the batch number ie BATCH0413 from the following text.

      <mastercomment4>[Comments2] 2ndcomment, [batch] BATCH0413, [update date] 13/4/11</mastercomment4>

      Is there a wat to ask FMP to select text between 2 delimiting strings?

      Thanks

        • 1. Re: select text between
          LaRetta_1

          There are several calculations which will get you there.  Here is one of them (result is text), where TEXT is the field to evaluate:

          Let ( start = Position ( TEXT ; "[batch]" ; 1 ; 1 ) + 7  ; LeftWords ( Middle ( TEXT ; start  ; Length ( TEXT ) ) ; 1 ) )

          If you would like to have a generic calculation to always understand how to pull between two specifed strings, you can use (in this example, gStart and gEnd can be two global text fields or you can insert the specific characters between quotes in their place:

          Let ( [
          start = Position ( TEXT ; gStart ; 1 ; 1 ) + Length ( gStart ) + 1 ;
          end =  Position ( Middle ( TEXT ; start  ; Length ( TEXT ) ) ; gEnd ; 1 ; 1 ) - 1
          ] ;
          Middle ( TEXT ; start ; end )
          )

          corrected calc by adding the +1 in bold

          • 2. Re: select text between
            lauriehughes

            Thanks so much, Ill give it a try