ee.String.trim
Returns a string whose value is the original string, with any leading and trailing whitespace removed.
Usage | Returns |
---|
String.trim() | String |
Argument | Type | Details |
---|
this: string | String | The string to trim. |
Examples
var s = ee.String('\t\n\r abc\t\n\r ');
print(s.trim()); // "abc"
var s = ee.String(' a\t\n\r b ');
print(s.trim()); // "a\t\n\r b"
Python setup
See the
Python Environment page for information on the Python API and using
geemap
for interactive development.
import ee
import geemap.core as geemap
s = ee.String('\t\n\r abc\t\n\r ')
print(s.trim().getInfo()) # "abc"
s = ee.String(' a\t\n\r b ')
print(s.trim().getInfo()) # "a\t\n\r b"
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[[["`trim()` removes leading and trailing whitespace characters (spaces, tabs, newlines, carriage returns) from a string."],["The function returns a new string without modifying the original string."],["Internal whitespace characters within the string are preserved."]]],["The `trim()` method removes leading and trailing whitespace from a string. It operates on a string (specified as `this: string`) and returns a new string with whitespace characters like tabs, newlines, and carriage returns removed from the beginning and end. Whitespace within the string remains unchanged. Examples in JavaScript and Python demonstrate trimming strings, showing the output after applying `trim()`.\n"]]