공지사항:
2025년 4월 15일 전에 Earth Engine 사용을 위해 등록된 모든 비상업용 프로젝트는 Earth Engine 액세스를 유지하기 위해
비상업용 자격 요건을 인증해야 합니다.
ee.String.slice
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
지정된 문자열의 하위 문자열을 반환합니다. 지정된 범위가 문자열의 길이를 초과하면 더 짧은 하위 문자열을 반환합니다.
사용 | 반환 값 |
---|
String.slice(start, end) | 문자열 |
인수 | 유형 | 세부정보 |
---|
다음과 같은 경우: string | 문자열 | 하위 집합으로 만들 문자열입니다. |
start | 정수 | 시작 색인(포함)입니다. 음수는 문자열의 끝에서부터 역으로 계산됩니다. |
end | 정수, 기본값: null | 종료 색인(제외)입니다. 기본값은 문자열의 길이입니다. 음수는 문자열의 끝에서부터 역으로 계산됩니다. |
예
코드 편집기 (JavaScript)
print(ee.String('').slice(0)); // ''
print(ee.String('').slice(-1)); // ''
var s = ee.String('abcdefghijklmnopqrstuvwxyz');
print(s.slice(0)); // abcdefghijklmnopqrstuvwxyz
print(s.slice(24)); // yz
print(s.slice(-3)); // xyz
print(s.slice(3, 3)); // ''
print(s.slice(2, 3)); // c
print(s.slice(-4, 25)); // wxy
Python 설정
Python API 및 geemap
를 사용한 대화형 개발에 관한 자세한 내용은
Python 환경 페이지를 참고하세요.
import ee
import geemap.core as geemap
Colab (Python)
print(ee.String('').slice(0).getInfo()) # ''
print(ee.String('').slice(-1).getInfo()) # ''
s = ee.String('abcdefghijklmnopqrstuvwxyz')
print(s.slice(0).getInfo()) # abcdefghijklmnopqrstuvwxyz
print(s.slice(24).getInfo()) # yz
print(s.slice(-3).getInfo()) # xyz
print(s.slice(3, 3).getInfo()) # ''
print(s.slice(2, 3).getInfo()) # c
print(s.slice(-4, 25).getInfo()) # wxy
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-07-26(UTC)
[null,null,["최종 업데이트: 2025-07-26(UTC)"],[[["\u003cp\u003e\u003ccode\u003eString.slice()\u003c/code\u003e extracts a portion of a string, returning a new string.\u003c/p\u003e\n"],["\u003cp\u003eIt uses \u003ccode\u003estart\u003c/code\u003e and \u003ccode\u003eend\u003c/code\u003e indices to define the substring, with \u003ccode\u003estart\u003c/code\u003e being inclusive and \u003ccode\u003eend\u003c/code\u003e exclusive.\u003c/p\u003e\n"],["\u003cp\u003eNegative indices are supported, counting backwards from the string's end.\u003c/p\u003e\n"],["\u003cp\u003eIf the specified range goes beyond the string's boundaries, a shorter substring within those boundaries is returned.\u003c/p\u003e\n"],["\u003cp\u003eIt's applicable in both JavaScript and Python environments within the Earth Engine context.\u003c/p\u003e\n"]]],[],null,["# ee.String.slice\n\nReturns a substring of the given string. If the specified range exceeds the length of the string, returns a shorter substring.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|--------------------------------|---------|\n| String.slice`(start, `*end*`)` | String |\n\n| Argument | Type | Details |\n|----------------|------------------------|---------------------------------------------------------------------------------------------------------------------------------|\n| this: `string` | String | The string to subset. |\n| `start` | Integer | The beginning index, inclusive. Negative numbers count backwards from the end of the string. |\n| `end` | Integer, default: null | The ending index, exclusive. Defaults to the length of the string. Negative numbers count backwards from the end of the string. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nprint(ee.String('').slice(0)); // ''\nprint(ee.String('').slice(-1)); // ''\n\nvar s = ee.String('abcdefghijklmnopqrstuvwxyz');\nprint(s.slice(0)); // abcdefghijklmnopqrstuvwxyz\nprint(s.slice(24)); // yz\nprint(s.slice(-3)); // xyz\nprint(s.slice(3, 3)); // ''\nprint(s.slice(2, 3)); // c\nprint(s.slice(-4, 25)); // wxy\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\nprint(ee.String('').slice(0).getInfo()) # ''\nprint(ee.String('').slice(-1).getInfo()) # ''\n\ns = ee.String('abcdefghijklmnopqrstuvwxyz')\nprint(s.slice(0).getInfo()) # abcdefghijklmnopqrstuvwxyz\nprint(s.slice(24).getInfo()) # yz\nprint(s.slice(-3).getInfo()) # xyz\nprint(s.slice(3, 3).getInfo()) # ''\nprint(s.slice(2, 3).getInfo()) # c\nprint(s.slice(-4, 25).getInfo()) # wxy\n```"]]