Brian Dunning's FileMaker Custom Functions

ZapChars ( textToZap ; zapText )

Filters out all characters in a specified string from the supplied text.

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

Ray Cologon   Ray Cologon
NightWing Enterprises
http://www.nightwing.com.au/FileMaker

Share on Facebook Share on Twitter

  Sample input:
ZapChars ( "* CobaltSky *" ; "y*obeliSk " )
  Sample output:
Cat

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

Here is a function which is the logical inverse of FileMaker 7's Filter( ) function. Whereas Filter( ) removes everything from the supplied text that is *not* in the filter string, this function removes everything that *is* in the zapText string, leaving everything else. Great for getting rid of a host of gremlin characters in one pass.

The function is case sensitive, so if you want to remove 'a' and also 'A' they must both be present in the zapText parameter.

It is possible to achieve the same result by performing multiple substitutions where every character to be removed is separately specified (each being replaced with a null) but for long strings of characters to be zapped, the ZapChars ( ) syntax is much more compact and manageable.

The function utilizes recursion to 'walk' the length of the supplied string omitting any characters that are present in the specified zapText.

 

Comments

Scott Zeigen MD   Scott Zeigen MD, Richboro PA
Feb 26, 2011
Works nice, removes the <CR> character, too
 

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 15 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: