Announcement: All noncommercial projects registered to use Earth Engine beforeApril 15, 2025 mustverify noncommercial eligibility to maintain access. If you have not verified by September 26, 2025, your access may be on hold.
ee.String.index Stay organized with collections Save and categorize content based on your preferences.
Page Summary
Searches a string for the first occurrence of a substring.
Returns the index of the first match or -1 if not found.
The search is case-sensitive.
| Usage | Returns |
|---|---|
String.index(pattern) | Integer |
| Argument | Type | Details |
|---|---|---|
this:target | String | The string to search. |
pattern | String | The string to find. |
Examples
Code Editor (JavaScript)
print(ee.String('abc123').index(''));// 0print(ee.String('abc123').index('c1'));// 2print(ee.String('abc123').index('ZZ'));// -1// index is case-sensitive.print(ee.String('abc123').index('BC'));// -1
Python setup
See the Python Environment page for information on the Python API and usinggeemap for interactive development.
importeeimportgeemap.coreasgeemap
Colab (Python)
display(ee.String('abc123').index(''))# 0display(ee.String('abc123').index('c1'))# 2display(ee.String('abc123').index('ZZ'))# -1# index is case-sensitive.display(ee.String('abc123').index('BC'))# -1
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-10-06 UTC.