Brian Dunning's FileMaker Custom Functions

TrimN ( text ; hitlist )

Removes any of a string of defined characters from leading/trailing positions on the supplied text

  Average rating: 4.5 (37 votes) Log in to vote

Ray Cologon   Ray Cologon - Show more from this author
NightWing Enterprises
http://www.nightwing.com.au/FileMaker

Share on Facebook Share on Twitter

  Sample input:
TrimN ( " * Smile for the camera!¶" , "*!?.,: ¶" )
  Sample output:
Smile for the camera

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

This function allows you to define the characters which are to be trimmed from the start and/or end of the supplied text on the fly. Thus you can selectively remove bullets, asterisks, elypses or other punctuation as well as leading/trailing numbers or whitespace.

There is no length limit on the hitlist, so the function can be used to selectively strip a number of unwanted leading/trailing characters in one call.

 

Comments

Dao   Dao
Dec 23, 2024
The function does not work properly.
Input :
TrimN ( " * Smile for ¶the camera!¶" ; "*!?.,: ¶" )

Output :
Smile for ¶
the camera

the ¶ is not removed
 
Ray Cologon   Ray Cologon, NightWing Enterprises
Dec 23, 2024
Hi Dao,
It appears you did not carefully read the description of this function, which states "Removes any of a string of defined characters from leading/trailing positions on the supplied text".

The character you are complaining has not been removed is in the middle of the string, whereas the function is explicitly designed to remove targeted characters only from the start or end of the supplied text.

Thus the function is working as designed and in accordance with the description. If you want a function that will remove characters from any location in the supplied text, you might wish to try ZapChars( ), which can be found at:

https://www.briandunning.com/cf/76

Regards,
Ray
 

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