Skip to main content

$trim

The $trim operator removes specified characters from both ends of a string.

Input

  • An array containing exactly two string values: the input string and the set of characters to trim

Output

  • The input string with specified characters removed from both ends

Examples

Trim Whitespace

{
  "$trim": [
    "  Hello, World!  ",
    " "
  ]
}
Result: "Hello, World!"

Trim Specific Characters

{
  "$trim": [
    "...Hello, World!...",
    "."
  ]
}
Result: "Hello, World!"

Field Value

{
  "$trim": [
    {
      "$input": "input_text"
    },
    " \t\n"
  ]
}
Result: The input_text field with leading and trailing whitespace removed