{"id":11569,"date":"2020-09-22T17:01:55","date_gmt":"2020-09-22T17:01:55","guid":{"rendered":"https:\/\/www.directimpactsolutions.com\/?p=11569"},"modified":"2025-03-17T01:28:38","modified_gmt":"2025-03-17T01:28:38","slug":"regular-expressions-regex-in-filemaker","status":"publish","type":"post","link":"https:\/\/www.directimpactsolutions.com\/en\/regular-expressions-regex-in-filemaker\/","title":{"rendered":"Regular Expressions (RegEx) in FileMaker"},"content":{"rendered":"<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"614\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-1024x614.jpg\" alt=\"RegEx in FileMaker\" class=\"wp-image-11776\" style=\"width:622px;height:373px\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-1024x614.jpg 1024w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-300x180.jpg 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-768x461.jpg 768w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-600x360.jpg 600w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker.jpg 1500w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure><p>Regular expressions (known as RegEx or RegExp) are patterns used to match character combinations in strings. RegEx can be used in FileMaker for a variety of purposes.<\/p><h3 class=\"wp-block-heading\">RegEx use cases include:<\/h3><ul class=\"wp-block-list\"><li>Validating field types (RegEx tests)<ul class=\"wp-block-list\"><li>For example:&nbsp;<mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\"><code>j.doe@example.org<\/code>&nbsp;<\/mark>is a valid email format while&nbsp;<code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">j@doe<\/mark><\/code>&nbsp;is not.<\/li><\/ul><\/li>\n\n<li>Finding certain patterns (RegEx match and MatchAll)<ul class=\"wp-block-list\"><li>For example: Check if IP addresses exists in&nbsp;<code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">I'm using the 1.1.1.1 and 8.8.8.8 public DNS servers<\/mark><\/code>&nbsp;and return them, the RegEx function would output both&nbsp;<code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">1.1.1.1<\/mark><\/code>&nbsp;and&nbsp;<code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">8.8.8.8<\/mark><\/code>.<\/li><\/ul><\/li>\n\n<li>Finding and replacing a text pattern (RegEx replace and ReplaceAll)<ul class=\"wp-block-list\"><li>For example: Redact all emails in&nbsp;<code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">My email addresses are jdoe@example.com and j.doe@gmail.com<\/mark><\/code>. The result would be&nbsp;<code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">My email addresses are [REDACTED] and [REDACTED]<\/mark><\/code>.<\/li><\/ul><\/li><\/ul><blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>\u201cA regular expression is a sequence of characters that define a search pattern. Usually such patterns are used by string-searching algorithms for \u201cfind\u201d or \u201cfind and replace\u201d operations on strings, or for input validation. It is a technique developed in theoretical computer science and formal language theory.\u201d<\/strong><\/p><cite>Source:&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Regular_expression\" target=\"_blank\" rel=\"noreferrer noopener\">Wikipedia<\/a><\/cite><\/blockquote><h3 class=\"wp-block-heading\">Regular Expressions (RegEx) in FileMaker<\/h3><p>Regular expressions can be implemented in&nbsp;<a href=\"https:\/\/directimpactsolutions.com\/en\/how-to-debug-javascript-in-filemaker\">FileMaker without advanced FileMaker or JavaScript<\/a>&nbsp;development skills.&nbsp;<\/p><p>In this blog post, I\u2019ll be only demonstrating RegEx tests for the sake of simplicity. Our next blog posts may cover topics such as Match, MatchAll, Replace, and ReplaceAll. I\u2019ve included a demo file that illustrates the concepts in this article. In the demo file, you\u2019ll find support for MatchAll, if that is useful for your solution.<\/p><h3 class=\"wp-block-heading\"><strong>Who uses RegEx?<\/strong><\/h3><p>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,&nbsp; regular expressions can be an easy way to reliably validate fields or scrape certain values from data without advanced FileMaker skills.&nbsp;<\/p><p>The attached demo file works only with FileMaker 19. Please comment if you require a demo file for previous versions of FileMaker.<\/p><h3 class=\"wp-block-heading\"><strong>RegEx Patterns<\/strong><\/h3><p>An example of a RegEx pattern is:&nbsp;<code><mark style=\"background-color:rgba(0, 0, 0, 0);color:#cf2e2e\" class=\"has-inline-color\">^[a-zA-Z0-9]+$<\/mark><\/code>. This pattern checks if the given string is made of alphanumeric characters only. You can use&nbsp;<a href=\"http:\/\/rick.measham.id.au\/paste\/explain.pl?regex=%5E%5Ba-zA-Z0-9%5D%2B%24\" target=\"_blank\" rel=\"noreferrer noopener\">this tool<\/a>&nbsp;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.<\/p><pre class=\"wp-block-code\"><code>^: the beginning of the string\n&#91;a-zA-Z0-9]+: \n  a-z: any character from 'a' to 'z'\n  A-Z: any character from 'A' to 'Z'\n  0-9: any number from '0' to '9' \n+: (1 or more times (matching the most amount possible))\n$: the end of the string<\/code><\/pre><h3 class=\"wp-block-heading\"><strong>Finding or Creating new RegEx Patterns<\/strong><\/h3><ul class=\"wp-block-list\"><li>Create your own using a tool such as&nbsp;<a href=\"https:\/\/regex101.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">regex101.com<\/a><\/li>\n\n<li>Use existing regular expressions patterns on&nbsp;<a href=\"https:\/\/regexlib.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">regexlib.com<\/a>&nbsp;or&nbsp;<a href=\"https:\/\/projects.lukehaas.me\/regexhub\/\" target=\"_blank\" rel=\"noreferrer noopener\">regexhub.com<\/a><\/li><\/ul><h3 class=\"wp-block-heading\"><strong>Integration overview<\/strong><\/h3><p>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&nbsp;<em>RegExTest(RegEx,string,modifiers)<\/em>. The result of the script is either&nbsp;<em>True<\/em>&nbsp;or&nbsp;<em>False<\/em>, depending on the result of the RegEx test. The demo file includes a simpler integration example that can be found in the Sandbox layout.<\/p><figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"926\" height=\"575\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_sandbox-1-1024x673-2.jpg\" alt=\"regular expressions in FileMaker demo\" class=\"wp-image-11573\" style=\"width:569px;height:353px\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_sandbox-1-1024x673-2.jpg 926w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_sandbox-1-1024x673-2-300x186.jpg 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_sandbox-1-1024x673-2-768x477.jpg 768w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_sandbox-1-1024x673-2-600x373.jpg 600w\" sizes=\"auto, (max-width: 926px) 100vw, 926px\" \/><\/figure><p>Sandbox layout.<\/p><figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1009\" height=\"651\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_val_fail-1024x659-1.jpg\" alt=\"regular expressions in FileMaker demo\" class=\"wp-image-11575\" style=\"width:571px;height:368px\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_val_fail-1024x659-1.jpg 1009w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_val_fail-1024x659-1-300x194.jpg 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_val_fail-1024x659-1-768x496.jpg 768w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_val_fail-1024x659-1-600x387.jpg 600w\" sizes=\"auto, (max-width: 1009px) 100vw, 1009px\" \/><\/figure><p>Example of a failed validation check through a RegEx Test.<\/p><figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1011\" height=\"655\" src=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_val_success-1024x662-1.jpg\" alt=\"regular expressions in FileMaker demo\" class=\"wp-image-11577\" style=\"width:570px;height:369px\" srcset=\"https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_val_success-1024x662-1.jpg 1011w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_val_success-1024x662-1-300x194.jpg 300w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_val_success-1024x662-1-768x498.jpg 768w, https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/regex_val_success-1024x662-1-600x389.jpg 600w\" sizes=\"auto, (max-width: 1011px) 100vw, 1011px\" \/><\/figure><p>Example of a successful validation check through a RegEx Test.<\/p><h3 class=\"wp-block-heading\"><strong>Try it out<\/strong><\/h3><ol class=\"wp-block-list\"><li>Open the demo file and make sure you\u2019re on the \u201cSimple Demo\u201d layout<\/li>\n\n<li>Enter a valid email address in the \u201cEmail\u201d field<\/li>\n\n<li>Click the \u201cCheck if valid email address\u201d button<\/li>\n\n<li>You should see a dialog window showing a successful validation check<\/li>\n\n<li>Enter an invalid email address such as \u201cjdoe@example\u201d<\/li>\n\n<li>Click the \u201cCheck if valid email address\u201d button<\/li>\n\n<li>You should see a dialog window showing a failed validation check<\/li><\/ol><p>Open the \u201cSample form\u201d layout to see an example of how to use this flow with the OnObjectValidate field trigger. If you don\u2019t want to see the dialog messages, you can disable them in the \u201cRegExValidateField(String\u00b6Type)\u201d script.<\/p><h3 class=\"wp-block-heading\">Conclusion<\/h3><p>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&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Extract,_transform,_load\" target=\"_blank\" rel=\"noreferrer noopener\">ETL<\/a>&nbsp;(Extract, transform, load) tasks. There\u2019s a lot more that can be done with that wasn\u2019t 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.<\/p><h3 class=\"wp-block-heading\"><strong>RegEx explainers, resources and advanced testing tools<\/strong><\/h3><ul class=\"wp-block-list\"><li>Regex101 (excellent tool):&nbsp;<a href=\"https:\/\/regex101.com\/r\/hU2dI0\/1\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/regex101.com\/r\/hU2dI0\/1<\/a><\/li>\n\n<li>W3schools.com (RegEx tutorial):&nbsp;<a href=\"https:\/\/www.w3schools.com\/jsref\/jsref_obj_regexp.asp\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/www.w3schools.com\/jsref\/jsref_obj_RegExp.asp<\/a><\/li>\n\n<li>RegEx explainer:&nbsp;<a href=\"http:\/\/rick.measham.id.au\/paste\/explain.pl?regex=%5E%5Ba-zA-Z0-9%5D%2B%24\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/rick.measham.id.au\/paste\/explain.pl?regex=%5E%5Ba-zA-Z0-9%5D%2B%24<\/a><\/li><\/ul><hr class=\"wp-block-separator has-alpha-channel-opacity\" style=\"margin-top:var(--wp--preset--spacing--70);margin-bottom:var(--wp--preset--spacing--70)\"\/><p class=\"has-small-font-size\"><em>*This article was originally written for AppWorks, which has since joined Direct Impact Solutions. This article is intended for informative purposes only. To the best of our knowledge, this information is accurate as of the date of publication.<\/em><\/p>","protected":false},"excerpt":{"rendered":"<p>Regular expressions (known as RegEx or RegExp) are patterns used to match character combinations in strings. RegEx can be used in FileMaker for a variety of purposes. RegEx use cases include: \u201cA regular expression is a sequence of characters that define a search pattern. Usually such patterns are used by string-searching algorithms for \u201cfind\u201d or &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/www.directimpactsolutions.com\/en\/regular-expressions-regex-in-filemaker\/\"> <span class=\"screen-reader-text\">Regular Expressions (RegEx) in FileMaker<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":6,"featured_media":11776,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","footnotes":""},"categories":[29],"tags":[39,215,216],"class_list":["post-11569","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-low-code","tag-filemaker","tag-regex","tag-regular-expressions"],"uagb_featured_image_src":{"full":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker.jpg",1500,900,false],"thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-150x150.jpg",150,150,true],"medium":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-300x180.jpg",300,180,true],"medium_large":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-768x461.jpg",768,461,true],"large":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-1024x614.jpg",1024,614,true],"1536x1536":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker.jpg",1500,900,false],"2048x2048":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker.jpg",1500,900,false],"woocommerce_thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-300x300.jpg",300,300,true],"woocommerce_single":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-600x360.jpg",600,360,true],"woocommerce_gallery_thumbnail":["https:\/\/www.directimpactsolutions.com\/wp-content\/uploads\/2023\/05\/RegEx-in-FileMaker-100x100.jpg",100,100,true]},"uagb_author_info":{"display_name":"Direct Impact Solutions","author_link":"https:\/\/www.directimpactsolutions.com\/en\/author\/direct-impact-solutions\/"},"uagb_comment_info":0,"uagb_excerpt":"Regular expressions (known as RegEx or RegExp) are patterns used to match character combinations in strings. RegEx can be used in FileMaker for a variety of purposes. RegEx use cases include: \u201cA regular expression is a sequence of characters that define a search pattern. Usually such patterns are used by string-searching algorithms for \u201cfind\u201d or&hellip;","_links":{"self":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/11569","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/comments?post=11569"}],"version-history":[{"count":7,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/11569\/revisions"}],"predecessor-version":[{"id":19772,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/posts\/11569\/revisions\/19772"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/media\/11776"}],"wp:attachment":[{"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/media?parent=11569"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/categories?post=11569"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.directimpactsolutions.com\/en\/wp-json\/wp\/v2\/tags?post=11569"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}