3 Replies Latest reply on Sep 19, 2012 12:15 PM by philmodjunk

    Find/Replace Script



      Find/Replace Script


           Is there a way for me to find a word in a field and then look for another word that follows somewhere along the line? For instance. I would like to search the field and find the word "Harry," then I would like to find the first "<div>" after "Harry." I've tried so many differnet vairations of the find/replace function but none of them seem to work. Thanks.

        • 1. Re: Find/Replace Script

               You don't indicate whether you are alwasy looking for "Harry" or if this is a criterion specified by the user, but the technique is basically the same:

               Let ( Hpos = Position ( YourText ; "Harry" ; 1 ; 1 ) ;
                      Position ( YourText ; "<div>" ; Hpos ; 1 )

               Will return the position of the < in the first instance of "<div>" located after the first instance of "Harry".

          • 2. Re: Find/Replace Script

                 Thank you for the respone. This is a little beyond me. Could you tell me how I would put that into a script? Also how would I replace the <div> with <divider>. Please excuse my ignorance, but I am a casual Filemaker user. I thought I could just use the find and replace functions. Thanks for your kind help.

            • 3. Re: Find/Replace Script

                   As far as I know, Find and replace can't be set to search starting from a point inside the a block of text in a text field.

                   As a script you might do it this way:

                   Set variable [$DivPos ; value: Let ( Hpos = Position ( YourTable::YourTextField ; "Harry" ; 1 ; 1 ) ; Position ( YourText ; "<div>" ; Hpos ; 1 ) ) ]
                   If [$DivPos //make sure that <div> after "harry" was actually found]
                      Set Field [ YourTable::YourTextField ; Left ( YourTable::YourTextField ; $DivPos - 1 ) & "<divider>" &
                                                                             Right ( YourTable::YourTextField ; Length ( YourTable::YourTextField ) - $DivPos - 4 ) ]
                   End If