14 Replies Latest reply on Jul 15, 2016 8:35 AM by user25648

    identifying a sequence of characters

    user25648

      I'm having a difficult time trying to parse a certain sequence of characters.  The field from which I am parsing has too many variables from which I cannot consistently choose a pattern or location to use the left, right, middle, etc.  What I do know is that the field contains text in the following format:  xx-xxxxxx (whereby the x's are numerical characters).

       

      I'm sure there is a simple answer, but I've not been able to figure out how to extract just the xx-xxxxxx text into another field. 

       

      Help, anyone?

        • 1. Re: identifying a sequence of characters
          coherentkris

          if you can not find a pattern then you have to do it character by character.

          you could, in theory, convert the entire string to "N"'s, "L"'s and punctuation where N = any number character and L = any letter character then use position ( "NN-NNNNNN" ) then extract from the original text

          • 2. Re: identifying a sequence of characters
            siplus

            If there are no other numbers in the rest of the text, you can Filter(originalText; "0123456789-")

            • 3. Re: identifying a sequence of characters
              user19752

              What do you want if there are 2 or more found, or longer text like xxx-xxxxxxxxx ?

              • 4. Re: identifying a sequence of characters
                coherentkris

                note the ifs in siplus and user 19752 responses?

                For us to suggest an effective solution we need better understanding of the problem domain.

                If the op can effectively define the PD then he/she might see the solution.

                lead a horse to water and let it drink on its own

                • 5. Re: identifying a sequence of characters
                  user25648

                  The text I'm extract varies from a couple hundred words to over 1000 words.  Mixture of numbers, text, names, document numbers, dates, etc etc. So filtering specific characters is not an option.

                  • 6. Re: identifying a sequence of characters
                    user25648

                    I don't believe there will be more than one occurrence, and if there is it should be identical.  However, there will be occurrences of the longer text like xxx-xxxxxxxxxxxx.  In fact, the one pattern of xx-xxxxxx is only one of several patterns I need to extract.  I was hoping to "master" extracting one then applying the process to the others.

                    • 7. Re: identifying a sequence of characters
                      user25648

                      My problem is that I'm working with variable text of variable length for which there are approximately 15 variable, but known, patterns (such as xx-xxxxx) that I want to extract. 

                       

                      Each variable, known sequence exists in only a percentage of the records. 

                       

                      The first sequence I asked about has space characters surrounding the text which I didn't mention before:

                       

                      " xx-xxxxxx "

                       

                      For me, it doesn't matter what other text exists before or after as long as I can extract this specific sequence from the records in which this sequence exists.  This particular sequence only has numbers, but of the other 14 patterns I'm looking for, there will be a mixture.  One of them has a pattern of " xxx-xx-Fxx " where x is numeric and "F" is the letter F.

                       

                      Knowing how to extract multiple occurrences of this text would be helpful, but not necessary for this particular pattern. 

                       

                      coherentkris... did I give enough info?  Without going line by line and searching each line for the pattern, I'm not sure what to do (is there such a thing?)

                      • 8. Re: identifying a sequence of characters
                        siplus

                        I see a problem when you have 12-123456 and 312-12345678 in the same text.

                         

                        What you can do is to to replace the spaces in your text with ¶, producing a list, then go through the list with GetValue() and see if the element contains "-" and is longer than 1. If yes, add it to a second list.

                        • 9. Re: identifying a sequence of characters
                          PeterDoern

                          This is the approach I would take.. you could either script it or use the useful CustomList() custom function which you will find at fmfunctions.com

                          • 10. Re: identifying a sequence of characters
                            user25648

                            I'm trying to connect the dots with what I know and for other things I'm working through, so please bear with me as I ask a different sort of question.

                             

                            I know that I can bold the word " Document " in a record using a combination of substitute and text format functions. 

                            Is there a way for me to tell Filemaker to bold a sequence of text " xx-xxxxxx " where the "x" is any alpha-numeric character?

                            • 11. Re: identifying a sequence of characters
                              user25648

                              PeterDoern,

                               

                              I've been using custom functions.  And, though I don't always understand the underlying programming, I have been able to figure out how to apply the function to what I need.  Several I've been using regularly of late include ParseBetween, SubstituteRange, SubstituteWildcardRange, MagicDates, Trim4 and several others.

                               

                              But, when I look at the CustomList() function you've directed me to, I have no idea what to do with it.  How does it apply to finding " xx-xxxxxx " ? 

                              • 12. Re: identifying a sequence of characters
                                Korry

                                A regular expression could do what you want. Example for your case: https://regex101.com/r/gR8yE6/1

                                 

                                Sadly, FileMaker doesn't natively offer regex functions, but check out https://community.filemaker.com/thread/68436

                                1 of 1 people found this helpful
                                • 13. Re: identifying a sequence of characters
                                  PeterDoern

                                  I suggested the CustomList() function as part of a solution as proposed by siplus: to convert your text field into a carriage return-delimited list, which you would either loop through via script or the CustomList() function to process each value.

                                   

                                  However, as Korry suggests you might also want to look into a custom function that can perform regular expressions on the text, i.e. pattern matching.

                                   

                                  If you ask 3 FileMaker developers how to do something, expect 10 different answers.

                                  1 of 1 people found this helpful
                                  • 14. Re: identifying a sequence of characters
                                    user25648

                                    Thanks to all who helped decipher what I was trying to ask.. 

                                     

                                    Korry and PeterDoern.... you've both pointed me in what appear to be good directions for what I need and am (will be) capable of doing with my present level of experience.   Looks like I need to do some more reading up to see what will work best in the long haul for this particular need. 

                                     

                                    Regardless, both of you have directed me to resources I need and am interested in learning more about.