RegEx in a WebViewer to match letter combinations against a dictionary

Document created by steve_ssh on Aug 21, 2018Last modified by steve_ssh on Aug 22, 2018
Version 9Show Document
  • View in full screen mode



This document is home to a proof-of-concept file that was entirely inspired by this fun post.


On that post, a number of us were having fun chiming in about various approaches to solving a topic that evolved from finding permutations of strings to matching combinations of letters with wildcards.


I enjoyed that post thoroughly, and decided it would be fun to try implementing a JavaScript approach that was inspired by comments from practically all of the thread participants.


The attached file takes a collection of letters and wildcard chars as input.  It then takes that input and attempts to use it to quickly find matches against a dictionary of words stored within the FMP file.  Per the post that inspired this, the matches are made by using any permutation of the supplied letters, or any substring of a permutation, i.e. it matches anagrams and also anagrams of every subset of the supplied letters (and wildcards).




Some misc. comments:


    • Being able to leverage RegEx was what really made this approach easy and performant.

    • The most difficult task was finding a list of English words to populate the dictionary.

    • The dictionary data is stored in a container field, and then exported to the FMP temp directory at runtime.  This helps save file space.

    • Please be warned that the dictionary data may contain questionable words; I did not go to efforts to proof the word data I found beyond easy catches.

    • This solution is WebViewer based, and thus comes with the usual caveats, such as:

                - The wrong version of FMP launching

                - Reduction of security by allowing FMP URL access

    • The demo file successfully runs on my older iPad, though, not surprisingly, it is not as fast.  As an example: A query that takes .9 seconds on my desktop machine took around 6-7 seconds on the iPad.




    • Tested using v.16 and v.17 of FMPA on MacOS High Sierra

    • A modified version that is compatible with v.15 of FMP tested on MacOS High Sierra, as well as an old iPad Mini, running FMGo v.15

    • Still not tested on Windows



Update 21 Aug 2018 11:30 pm Pacific: I just realized that I used one of my own MacOS-only Custom Functions in this file.  Until I either update the CF to be cross-platform compatible, or otherwise adjust the scripting in the demo-file, the demo is unlikely to work on Windows.  I'll do my best to patch this up, though it may be a few days before I can get to it.  Sincere apologies for any inconvenience.


Update 22 Aug 2018 9:40 pm Pacific: I have worked on the CF that was not cross platform, and have modified that CF so that it may now be Windows compatible. (This still remains to be tested).  In the course of fixing up this CF, I realized that it previously was also incompatible with respect to iOS.  This has been addressed, and I can confirm that a modified version of the demo file can successfully run using FMGo v.15 on iOS 9 (first generation iPad mini).  To anyone who may have downloaded a previous version of the demo file, I recommend replacing it with the latest version:





Attached should be the demo file that does the matching, as well as a clone copy of the FMP file which can be used to generate the needed dictionary file that is embedded in the demo file.  Having both of these should allow for updating the dictionary data in a fairly straightforward manner.





Thanks go to everyone who contributed on the original thread, and also to flybynight, whose post on the MacOS preference pane for mapping URL protocols was a big help.  Thanks for taking a look.


Kind regards,





p.s.  Is there anyone else who instinctively tries using Command/Control-L when they want to open a Community document for editing?

4 people found this helpful