String TrimSpace
The string::trimspace
function removes all leading and trailing whitespace characters, including newlines, from a string.
Syntax
string::trimspace(<string>)
Parameters
string
: The input string to be trimmed.
Returns
- String: A new string without leading or trailing whitespace or newline characters.
Example
string::trimspace("\n hello world \n")
This function is useful for cleaning up strings by removing unwanted spaces and newline characters at the start and end.