text.trim ( )

Function stats

Average user rating
5.0000
37
355
9999
Support
FileMaker 7.0 +
Date posted
20 April 2013
Last updated
23 April 2013
Version
Recursive function
No

Author Info
 Fabrice

74 functions

Average Rating 4.4

author_avatar



 

Function overview

Prototype

text.trim  ( _text )


Parameters

_text  the text to trim


Description

Tags:  Text   List   Array  

Another trim function.
(An alternative to SuperTrim)

Removes leading and trailing carriage returns, line feeds, vertical tabs, blanks...

Why use it?
Ideal to remove the CR appended by functions such as RightValues, LeftValues, or to fix copied/pasted data using auto enters.

Why another one?
Because all others seem too complex for the purpose.

Examples

Sample input

text.trim ( char(9) & char ( 10 ) & char ( 11) & "¶ Hello World¶How are you today?¶ " )


Sample output

Hello World¶How are you today?

 

Function code

/* text.trim ( _text )
by Fabrice Nordmann, 1-more-thing
twitter: 1morethingtweet
v1. Apr 2013

Another trim function.

Removes leading and trailing carriage returns, line feeds, vertical tabs, blanks...

Why use it?
Ideal to remove the CR appended by functions such as RightValues, LeftValues, or to fix copied/pasted data using auto enters.
/!\ CAUTION /!\, this will also remove some leading/trailing punctuation (all word separators), so use it on a list of IDs, but not for 'literature'

Why another one?
Because all others seem too complex for the purpose.

And now the amazing code:
*/

middlewords ( _text ; 1 ; length ( _text ))

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/355

    Prototype: text.trim( _text )
    Function Author: Fabrice (http://www.fmfunctions.com/mid/37)
    Last updated: 23 April 2013
    Version: 2.1

*/
// ===================================

 

Comments

Andries Heylen
23 April 2013



pooh, this is just too easy :)

nice find!
  General comment
menno
28 April 2013



Nice find Fabrice, however Tabs, underscores and spaces between the words aren't removed (and the function wordcount instead of length gives you the same result). Only the leading and trailing ones are and the crtn's inbetween are removed, double spaces and tabs are not. I would expect general trim to also remove double spaces and replace any amount of tabs with one space. Maybe you'd like to expand your cf a little? Is it still a simple then?
Sorry man, no offence meant, but you started complaining about too complex functions ;-)
  General comment
Fabrice
28 April 2013



well, maybe you're looking for the Substitute function :)
This function does what it says it does, nothing more.
I use it to remove crs added by LeftValues, RightValues, MiddleValues and FilterValues.

Note : length is faster than wordcount, that's why.
(Edited by Fabrice on 28/04/13 )
  General comment
menno
30 April 2013



OK I didn't that length is faster. Thanks for pointing that out.
  General comment
Paul Jansen
07 June 2013



Why not just use 999999 instead of length? is that not faster still?
  General comment

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (31)
Date  (28)
XML  (26)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (12)
Layout Objects  (11)
Filter  (11)
Design  (10)
Array  (7)