trim - Clean whitespace from a string
The trim
function removes whitespace from the start and end of a given string
value.
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
value | string | true | The string from which to remove whitespace |
Example - Cleaning up an extracted username
Consider the following document:
We want to extract the username from this string, so that we can search and query it directly. This can be done using the extract
keyword with a regular expression.
This results in this log object:
Notice the space at the start and end of the username. This is because a stray space has made its way in. We can use trim
to clean this up:
This will remove the spaces from the username and result in a cleaner value.
Theme
Light