6 Replies Latest reply on Feb 10, 2012 1:09 PM by MarcMcCall

    Parsing text after a variable.

    MarcMcCall

      Title

      Parsing text after a variable.

      Post

      Ok, so last night i thought I had the answer to my problem, but after a good night sleep, I realized the formula I used is only giving me a portion of the data I need.  I need to parse all text in a field that has multiple cariage returns, but all of the text I need always follows "For use in:"

      It will look like this:

       

      OEM Brother® LC612PKS Black 2/PK Ink Cartridges

      Yields up to 450 Pages @ 5% Coverage

      For use in:
      Brother MFC: J220, J265w, J270w, J410w, J415w, J615w, J630w, 795Cw, 990cw, 5490cn, 5890cn, 5895cw, 6490cw, 6890cdw
      DCP: J125, 165c, 385c, 395cn

       

      As you can see, the text will always vary in lenght, but the text I want is always preceeded by "For use in:" Sometimes there may be up to 15-20 lines after the "For use in:" with multiple cariage returns.

        • 1. Re: Parsing text after a variable.
          philmodjunk

          Position ( YourField ; "For use in:" ; 1 ; 1 )

          Will return the position of the F in the first instance of "for use in:" found in your text field. (Look this one up to understand the 1 : 1 parameters and what other options you can use.

          If you don't know how many lines of text come before "for use in:" use this function to find the location. If the number of lines of text that come before this phrase are always the same, you can set up a simpler expression using leftValues.

          LeftValues ( YourField ; 4 )

          Returns the first 4 lines of text plus an extra return after the last line, to give one example. GetValue and MiddleValues can also be options when you need a portaion of the lines of text preceding this phrase.

          None of these approachs are affected by the number of lines of text that come after this phrase.

          • 2. Re: Parsing text after a variable.
            MarcMcCall

            I've tried 20 variations of these, and still cant seem to get the formula correct.  It keeps giving me the text befor "For us in:".  I've tried Right Middle IDK, I just can't seem to quite get it..

            • 3. Re: Parsing text after a variable.
              philmodjunk

              See if this works:

              Let ( [ T = YourTable::YourTextField ;
                         L = Length ( T ) ;
                         Start1 = Position ( T ; "For use in:" ; 1 ; 1 ) ;
                         Start2 = Position ( T ; ¶ ; Start1 ; 1 )
                       ];
                       Right ( T ; Start2 ; L - Start2 ) 
                     )

              • 4. Re: Parsing text after a variable.
                MarcMcCall

                I've never used the Let function, I'm studying this to understand better, it comes up with an error.

                • 5. Re: Parsing text after a variable.
                  philmodjunk

                  I put in an extra parameter that shouldn't be there.

                  Right ( T ; Start2 ; L - Start2 )

                  Should be:

                  Right ( T ;  L - Start2 )

                  • 6. Re: Parsing text after a variable.
                    MarcMcCall

                    PhilModJunk,

                    You are the man!!!! Thanx so much. Working great.  I love working with FileMaker.  I hope to be as knowledgable as you one day.  I have used so many of your posts on here that I've found looking for answers to my questions. Thanx again.  This is really going to save me a tone of time getting this website together.