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.rindex Stay organized with collections Save and categorize content based on your preferences.
Page Summary
The
rindexmethod searches a string for the last occurrence of a substring.It returns the index of the first match, or -1 if no match is found.
The method takes two string arguments: the target string to search and the pattern string to find.
| Usage | Returns |
|---|---|
String.rindex(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('aBc-Abc').rindex('A'));// 4print(ee.String('aBc-Abc').rindex('a'));// 0print(ee.String('aBc-Abc').rindex('Bc'));// 1print(ee.String('aBc-Abc').rindex('Z'));// -1print(ee.String('aBc-Abc').rindex('-'));// 3print(ee.String('aBc-Abc').rindex(''));// 7
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('aBc-Abc').rindex('A'))# 4display(ee.String('aBc-Abc').rindex('a'))# 0display(ee.String('aBc-Abc').rindex('Bc'))# 1display(ee.String('aBc-Abc').rindex('Z'))# -1display(ee.String('aBc-Abc').rindex('-'))# 3display(ee.String('aBc-Abc').rindex(''))# 7
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 2024-07-13 UTC.