Regular Expressions (RegEx) in FileMaker

Regular expressions (known as RegEx or RegExp) are patterns used to match character combinations in strings. Use cases include:

  • Validating field types (RegEx tests)
    • For example: is a valid email format while j@doe is not.
  • Finding certain patterns (RegEx match and MatchAll)
    • For example: Check if IP addresses exists in I'm using the and public DNS servers and return them, the RegEx function would output both and
  • Finding and replacing a text pattern (RegEx replace and ReplaceAll)
    • For example: Redact all emails in My email addresses are and The result would be My email addresses are [REDACTED] and [REDACTED].

“A regular expression is a sequence of characters that define a search pattern. Usually such patterns are used by string-searching algorithms for “find” or “find and replace” operations on strings, or for input validation. It is a technique developed in theoretical computer science and formal language theory.”

Source: Wikipedia

Regular expressions can be implemented in FileMaker without advanced FileMaker or JavaScript development skills. 

In this blog post, I’ll be only demonstrating RegEx tests for the sake of simplicity. Future blog posts may cover topics such as Match, MatchAll, Replace, and ReplaceAll. The demo file attached includes support for MatchAll, if that is useful for your solution.

Who is this for?

Regular expressions are useful for both FileMaker power users and developers. The use of regular expressions will make your work as a developer more efficient. For FileMaker beginners,  regular expressions can be an easy way to reliably validate fields or scrape certain values from data without advanced FileMaker skills. 

The attached demo file works only with FileMaker 19. Please comment if you require a demo file for previous versions of FileMaker.

RegEx Patterns

An example of a RegEx pattern is: ^[a-zA-Z0-9]+$. This pattern checks if the given string is made of alphanumeric characters only. You can use this tool to retrieve an explanation of a specific RegEx pattern. A list of resources, including tools about this topic, can be found at the end of this article.

^: the beginning of the string
  a-z: any character from 'a' to 'z'
  A-Z: any character from 'A' to 'Z'
  0-9: any number from '0' to '9' 
+: (1 or more times (matching the most amount possible))
$: the end of the string

Finding or Creating new RegEx Patterns

Integration overview

I prepared a script in JavaScript that can receive a string, a RegEx pattern and RegEx modifiers. RegEx tests can be executed using a script called RegExTest(RegEx,string,modifiers). The result of the script is either True or False, depending on the result of the RegEx test. The demo file includes a simpler integration example that can be found in the Sandbox layout.

Sandbox layout.
Field validation flow. Flowchart made using mermaid-js.
Example of a failed validation check through a RegEx Test.
Example of a successful validation check through a RegEx Test.

Try it out

  1. Open the demo file and make sure you’re on the “Simple Demo” layout
  2. Enter a valid email address in the “Email” field
  3. Click the “Check if valid email address” button
  4. You should see a dialog window showing a successful validation check
  5. Now enter a invalid email address such as “jdoe@example”
  6. Click the “Check if valid email address” button
  7. You should see a dialog window showing a failed validation check

Open the “Sample form” layout to see an example of how to use this flow with the OnObjectValidate field trigger. If you don’t want to see the dialog messages, you can disable them in the “RegExValidateField(String¶Type)” script.


Regular expressions are very handy for extracting, validating and replacing strings and other data types. Using regular expressions should save developers a lot of time and improve the accuracy and capabilities of FileMaker scripts and functions, especially when it comes to ETL (Extract, transform, load) tasks. There’s a lot more that can be done with that wasn’t covered by this blog post and I hope that I get to cover more topics related to Regular Expressions (RegEx) in FileMaker. Let me know in the comments if you need help with the demo file, or need help implementing RegEx into your workflows.

RegEx explainers, resources and advanced testing tools