6 Replies Latest reply on Oct 8, 2012 8:20 PM by sporobolus

    Regex Opportunities

    nickchapin

      I'd like to open a discussion about using regex in FMP.

       

      I'm aware that it can be used in quite a few ways to validate data, find/replace specific instances of data within fields and records, and it can help solve a host of textual situations that native FM cannot accomplish (or can but slowly, relative to regex). I'm currently using it to validate data, particularly validating user-definable dynamic value lists (vl name and actual value).

       

      Which plugin or set of CFs are you using?

       

      What regex language are you using? Perl? Java? Something else?

       

      Have you developed a cool way to use regex in your daily workload? Maybe a new way to perform an older FM technique that's quicker or more extensible?

       

      How are you using regex?

       

       

      Nick

        • 1. Re: Regex Opportunities
          OllyGroves

          Can't say I've leveraged regex much, I should learn it I know, sys admin's I work with use it all day long with the like of grep, awk.  If I can 'borrow' a custom function that does the job (or close enough) i'll go with that.

           

          I've played with http://www.dracoventions.com/products/2empowerFM/family/regex.php little while back (Free Plugin) - think he uses a perl regex engine.  Presume same engine that's in his excellent Developer Plugin ( i.e. can find db objects with regex search ).

           

          Also a guy called Shawn frequented FMForums long time ago, believe he was an engineer for FM inc. in v7/8 days.   He built a suite of regex custom functions as an experimental demo.  A quick google and amazingly he's still got the page of examples up here http://www.spf-15.com/fmExamples/ .   There's still gold in that there webpage.

          • 2. Re: Regex Opportunities
            mbraendle

            I used once Jens Teich's RegEx plugin to text-mine author names from scanned and OCRed documents.

             

            And BTW, XML/XSLT CWP (in pre-FM12 times) has the fmxslt:regex_contains() extension function, which is mostly useful to check format of fields, e.g. e-mail addresses:

             

            <xsl:when test="fmxslt:regex_contains($email,'^\w+[\w-\.]*\@([\w-]+\.)+[a-z]{2,3}$') = false()">

             

            RegEx is ok for parsing single-line items with a highly-defined and restricted structure. However, in many cases, more advanced parsers, which can branch and choose the appropriate ruleset when the structure changes, are required.

            • 3. Re: Regex Opportunities
              mrwatson-gbs

              RegExp is a wonderful but quirky technology. Quirky to read and understand and use. Wonderful because, in my opinion, it is the only way to make really clean settings-driven solutions, that don't have to be reprogrammed for each customer.

               

              I love it, but then I am a programmer and IT-guy - not your general run-of-the-mill filemaker developer.

              (To be fair though I also hate it, because I use so seldomly (e.g. in TextMate Editor) that I have to re-learn it each time!)

               

              I would personally love to see it as a native FileMaker function - but probably it is too complex and non-FileMakerish for the FileMaker ethos of simplicity.

               

              In the many cases, however, you can live without it. E.g. Often when filtering value lists or lines of text, I find the three filter functions: LineBeginsWith, LineEndsEith and LineContains, cover the majority of cases. Thus in our LineFilter custom function I've implemented just the '^' and '$' RegExp characters. This means we can specify filter criteria in data (instead of reprogramming), but of course it does suffer from the CF-limit of 50000 lines.

               

              It is important to consider the costs of introducing such a technology into FileMaker/a solution:

               

              Once integrated into a solution (with plugin, or whatever) RegExp then becomes another technology that needs to be supported and understood by the FM-developers.

               

              On the other hand, there must be thousands of different solutions, that we have all implemented to fill the holes left by the lack of RegExp. This too comes at a price to the supportability and integration of solutions.

              • 4. Re: Regex Opportunities
                davidhamannmedia

                mrwatson-gbs schrieb:

                 

                I would personally love to see it as a native FileMaker function - but probably it is too complex and non-FileMakerish for the FileMaker ethos of simplicity.

                 

                You should suggest it here: https://fmdev.filemaker.com/community/discuss/pmqa (...and hope they'll put it on their to do list)

                • 5. Re: Regex Opportunities
                  nickchapin

                  Thanks, pixi, I hadn't seen that one. It's downloading now. Since I was already a user of Dracovention's dev plugin, their text plugin was the obvious choice for me. (And yes, you're correct, Olly, in that it uses Perl.) I had also looked at Shawn's file a while back but found it too cumbersome for me. (But still a fine example of what one can do with CFs!)

                   

                  Thanks for the reminder, Martin, about the fmxslt inclusion; I had completely forgotten about that!

                   

                  I agree that it's a quirky technology and I too am always having to "re-learn" the language each time I want to use it. (Someday I may get smart and put all of my common bits in, oh I don't know, a database.)

                   

                  Mr. Watson: can you give us a description of what you're filtering and how regex has helped keep your solution clean?

                  • 6. Re: Regex Opportunities
                    sporobolus

                    on 2012-10-08 3:06 mrwatson-gbs wrote

                    I would personally love to see it as a native FileMaker function - but probably it is too complex and non-FileMakerish for the FileMaker ethos of simplicity.

                     

                    i'd note XSLT, SQL, Tomcat and AppleScript as complex standard technologies

                    FileMaker has incorporated

                     

                    in fact, one way to incorporate regular expressions into FileMaker would be to

                    add the REGEXP SQL operator (as in MySQL) or one of the several other SQL regex

                    syntaxes

                     

                    also consider Adobe InDesign, which has deeply integrated regular expressions

                    features; despite a user base that is mostly non-developers, the power of

                    regular expressions has come to be well-appreciated by those whom it helps with

                    gnarly production tasks