Skip to content

trim

trim

📝 String

Remove leading and trailing whitespace from a string

trim(string) → string
string

The input string with leading and trailing whitespace removed; null if input is null

The trim function removes whitespace (spaces, tabs, newlines, etc.) from the beginning and end of the input string.

  • If string is null, returns null
  • Only removes leading and trailing whitespace; internal whitespace is preserved
  • trim("") returns ""
  • trim(" hello ") returns "hello"
  • Whitespace includes spaces, tabs (\t), newlines (\n), carriage returns (\r), etc.
| eval clean_message = trim(message)

Removes leading/trailing whitespace from message, useful for data cleanup.

| where trim(user_input) != ""

Filters to non-empty user input (after removing whitespace).

| eval normalized_tag = lower(trim(tag))

Normalizes tags by trimming whitespace and converting to lowercase.

  • eval — to create or transform string fields