strings.trim
strings.trim(string_to_trim, cutset)
Description
Trims leading and trailing white spaces from a given string. Also, remove unwanted characters (specified by the cutset argument) from the input string.
Param data types
STRING
, STRING
Return type
STRING
Code samples
The following are example use cases.
Example 1
In the following example, the same string is passed as the input string and the cutset, which results in an empty string.
strings.trim("str", "str") // ""
Example 2
In the following example, an empty string is passed as the cutset, which results in the original string str because there are no characters specified in the cutset to remove.
strings.trim("str", "") = "str"
Example 3
In the following example, the function yields an empty string because the input string is already empty and there are no characters to remove.
strings.trim("", "str") = ""
Example 4
In the following example, the function yields str because the trim function removes the following:
- trailing whitespace in "a aastraa aa "
- the characters specified in the cutset (space, a)
strings.trim("a aastraa aa ", " a") = "str"