String.trim
String.trim
Function
Remove leading and trailing whitespace characters from the string and return a new string.
Syntax
string.trim()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| String | Returns a new string with leading and trailing whitespace removed. |
Example
text = ' hello BT ' result = text.trim() // Output: hello BT print result
Notes
- The original string is not modified.
- Only the leading and trailing blanks are removed, and the blanks in the middle of the string are not processed.