trim
trim
📝 StringRemove 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.
Edge Cases
Section titled “Edge Cases”- If
stringisnull, returnsnull - 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.
Examples
Section titled “Examples”| 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.
Used In
Section titled “Used In”eval— to create or transform string fields