ee.String.trim
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Renvoie une chaîne dont la valeur est la chaîne d'origine, sans les espaces de début et de fin.
Utilisation | Renvoie |
---|
String.trim() | Chaîne |
Argument | Type | Détails |
---|
ceci : string | Chaîne | Chaîne à supprimer. |
Exemples
Éditeur de code (JavaScript)
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"
Configuration de Python
Consultez la page
Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap
pour le développement interactif.
import ee
import geemap.core as geemap
Colab (Python)
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"
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/26 (UTC).
[null,null,["Dernière mise à jour le 2025/07/26 (UTC)."],[[["\u003cp\u003e\u003ccode\u003etrim()\u003c/code\u003e removes leading and trailing whitespace characters (spaces, tabs, newlines, carriage returns) from a string.\u003c/p\u003e\n"],["\u003cp\u003eThe function returns a new string without modifying the original string.\u003c/p\u003e\n"],["\u003cp\u003eInternal whitespace characters within the string are preserved.\u003c/p\u003e\n"]]],["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"],null,["# ee.String.trim\n\nReturns a string whose value is the original string, with any leading and trailing whitespace removed.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-----------------|---------|\n| String.trim`()` | String |\n\n| Argument | Type | Details |\n|----------------|--------|---------------------|\n| this: `string` | String | The string to trim. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nvar s = ee.String('\\t\\n\\r abc\\t\\n\\r ');\nprint(s.trim()); // \"abc\"\n\nvar s = ee.String(' a\\t\\n\\r b ');\nprint(s.trim()); // \"a\\t\\n\\r b\"\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\ns = ee.String('\\t\\n\\r abc\\t\\n\\r ')\nprint(s.trim().getInfo()) # \"abc\"\n\ns = ee.String(' a\\t\\n\\r b ')\nprint(s.trim().getInfo()) # \"a\\t\\n\\r b\"\n```"]]