Skip to content

trim

Written as trim(argnum flags):options in a transform expression.

Minimum arguments 1
Maximum arguments no limit
Default arguments 1
Argument modes SINGLE_PRIMITIVE, SINGLE_PRIMITIVE_ARRAY, MULTIPLE_PRIMITIVES

Trim one or multiple strings, by removing leading and trailing whitespaces from each string.

Features:

  • by default, only whitespaces (space, newline) chars are removed.
  • custom trim chars can be specified in options.

Argument Modes:

  1. Single string argument:
    • The single string argument is trimmed with default trim chars or those chars in options
  2. A string array argument:
    • Each string in the array is trimmed with default trim chars or those chars in options
  3. Multiple string arguments:
    • Each string argument is trimmed

Note: Since this transform may return a list/array as result, if needed you can turn on the ‘SPREAD_OUTPUT’ flag (denoted with upper case ‘S’) as “trim(S):{:options:}” to spread the result list items into the pipeline argument stack as separate arguments, instead of an array argument.

Flag Letter
spread_input s
noncaptive_input I
arg_num_flexible f

Trim default chars from a single string argument

Section titled “Trim default chars from a single string argument”
Input args: [" world\n"]
Transforms: "trim:"
Output: "world"

Trim custom chars from a single string argument

Section titled “Trim custom chars from a single string argument”
Input args: [" world\n"]
Transforms: "trim: "
Output: "world\n"

Trim custom chars from a string array argument

Section titled “Trim custom chars from a string array argument”
Input args: [["hello "," world\n"]]
Transforms: "trim: "
Output: ["hello","world\n"]

Trim custom chars from multiple string arguments

Section titled “Trim custom chars from multiple string arguments”
Input args: ["hello "," world\n"]
Transforms: "trim: "
Output: ["hello","world\n"]