PatternCount(): searching and counting occurrences in FileMaker
BeginnerPatternCount() counts how many times a substring appears in a text value. Learn how to use it for existence checks, occurrence counting, and basic text analysis.
What you'll learn
- How PatternCount counts occurrences of a substring
- How to use PatternCount as a boolean existence check
- Practical uses: validating email format, counting delimiters, checking for keywords
PatternCount ( text ; searchString ) returns the number of times searchString appears in text — returning 0 if not found and a positive integer for each occurrence found, making it ideal for both existence checks and counting.
Stuck is a valid status
Need a second brain on this one?
If this lesson just collided with your real schema, script stack, or deadline, book consulting and turn the confusion into a concrete plan.
Check whether a value contains a substring
PatternCount returns 0 if the substring is not found, so using it in an If condition acts as a boolean "contains" check. It is case-insensitive.
# Check if an email address contains @ If [ not PatternCount ( Contacts::email ; "@" ) ] Show Custom Dialog [ "Please enter a valid email address." ] Exit Script [ Result: False ] End If # Check if a text field contains a keyword If [ PatternCount ( Notes::body ; "urgent" ) ] Set Field [ Notes::flagged ; 1 ] End If
Sign in to track your progress and pick up where you left off.
Sign in to FM Dojo