Brian Dunning's FileMaker Custom Functions

antiFilter ( textToFilter ; filterAllow ; filterSubChar ; start ; stop ; textBuilt )

replace any character not specified in the allowed list with the substitute character

  Average rating: 4.4 (35 votes) Log in to vote

Michael Rauch   Michael Rauch
ShopWorks
http://www.shopworx.com

Share on Facebook Share on Twitter

  Sample input:
code.999-999-9999
  Sample output:
code 999 999 9999

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

The impetus for the custom function was to have a way to override FileMaker's built in word separators when using LeftWords (and other word evaluation functions). This tail recursive function will build a new string, substituting any non-allowed characters with the substitute character.

A call would look something like this...

Let(
[
textToFilter = TO::someField;
filterAllow = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
]
;
cf_AntiFilter (textToFilter ; filterAllow ; " " ; 1 ; Length (textToFilter) ; "")
)

 

Comments

pixi   pixi, berlin
May 5, 2012
wouldn't it be shorter to have it:

==============================

Case ( start < ( Length ( textToFilter ) + 1 );
Let([
charToSub = Middle ( textToFilter; start; 1);
textBuilt = Case ( IsEmpty ( Filter ( charToSub; filterAllow )); filterSubChar; charToSub )
];
textBuilt
)
& antiFilter ( textToFilter; filterAllow; filterSubChar; start + 1 )
)

==============================

pixi
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: