Filter() for extracting specific characters in FileMaker

Intermediate

Filter() returns only the characters from a text string that appear in a specified mask string — making it the standard tool for extracting only digits, only letters, or any custom character set.

What you'll learn

  • How Filter() uses a mask to extract matching characters
  • Practical patterns: extracting digits, letters, alphanumeric characters
  • How to combine Filter() with Length() or comparison to validate input

Filter ( text ; filterMask ) returns only the characters from text that also appear in filterMask — stripping everything else — making it ideal for sanitizing phone numbers, extracting digits, or cleaning user input.

1/3
1

Extract only digits from a string

Pass only the digit characters as the mask. Filter() returns every digit in the input, in order, stripping all non-digit characters.

FileMaker Script
// Extract only digits
Filter ( Contacts::phone ; "0123456789" )
// "(555) 123-4567" → "5551234567"

// Validate: a US phone number must have exactly 10 digits
If [ Length ( Filter ( Contacts::phone ; "0123456789" ) ) ≠ 10 ]
  Show Custom Dialog [ "Please enter a 10-digit phone number." ]
  Exit Script [ Result: False ]
End If

Sign in to track your progress and pick up where you left off.

Sign in to FM Dojo