trim ... (string function)

Prev Next

Function Names

trim, trim all

Description

Trims excess white spaces (including tabs, new line symbols and other invisible control characters) from the beginning and end of the string. trim trims excessive spaces from beginning and ends, but leave spaces inside the string untouched.
trim all also removes redundant white blanks inside the string and replaces them by single spaces. I.e. new line symbols are also replaced by spaces.
Non-break space symbols are not affected.

Call as: function

Restrictions

Indirect parameter passing is disabled

Parameter count

1

Parameters

No.TypeDescription
1
input
string input string

String to be trimmed

Return value

TypeDescription
string trimmed string

Excess white spaces removed according to function chosen

Examples

      echo( '"', trim    ( "  This   is a green  cat "), '"' );
      echo( '"', trim all( "  This   is a green  cat "), '"' );

Output

"This   is a green  cat"
"This is a green cat"
Try it yourself: Open LIB_Function_trim.b4p in B4P_Examples.zip. Decompress before use.

See also

trim [parameter set function]