3 Replies Latest reply on Oct 26, 2008 11:31 AM by rmanook

    Find a text string between 2 delimiter characters

    Lawrence2

      Title

      Find a text string between 2 delimiter characters

      Post

      Hello, I need a way to find the string of text that is between 2 delimiter characters. For example, if a field contains: "New York is on the /Eastern/ seaboard" ; I need to find the string "Eastern" which is delimited by the forward slashes. Thanks.

       

        • 1. Re: Find a text string between 2 delimiter characters
          rmanook

          Hi Lawrence,

          Thanks for posting!  

           

          Here's one way to do this:

          Let's assume that we have a Test field (text) and a Test_c field (calc).  Set up your Test_c calculation so that it looks like the following (you can rename the variables in the Let function if you'd like, I just kept them as var 1/var 2 for a basic interpretation for this example):

           

          Let ( [var 1 = Position ( Test ; "/" ; 1 ; 1 ) + 1 ; var 2 = Position ( Test ; "/" ; 1 ; 2 ) - var 1 ] ;

          Middle ( Test ; var 1 ; var 2 ) ) 

           

          Our calculation field will now pick up the first two occurrences of the "/" symbol and will give us the text string in between.  Hopefully this helps, let me know if there is anything else I can clarify for you.

          Thanks!

          tsturtle

          FileMaker, Inc. 

          • 2. Re: Find a text string between 2 delimiter characters
            Lawrence2
               Thank you Turtle, may I ask if there is something special about the backslash? In your calculation "/" works fine, but when I change it to "\" I get an error.
            • 3. Re: Find a text string between 2 delimiter characters
              rmanook

              Hi Lawrence,

               

              Sorry, I was going off of the "New York is on the /Eastern/ seaboard" you had posted.  In a calculation, the backslash or '\' marks an operator character as just a character.  If you want to search for a backslash, modify the calculation so that it looks like this:

               

              Let ( [var 1 = Position ( Test ; "\\" ; 1 ; 1 ) + 1 ; var 2 = Position ( Test ; "\\" ; 1 ; 2 ) - var 1 ] ;

              Middle ( Test ; var 1 ; var 2 ) )  

               

              This way, we're letting the calculation know that we're searching for the backslash as a character in your text string. 

              Let me know if there is anything else I can clarify!

              tsturtle

              FileMaker, Inc.