Announcement: All noncommercial projects registered to use Earth Engine before April 15, 2025 must verify noncommercial eligibility to maintain Earth Engine access.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-06 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eindex()\u003c/code\u003e method searches a string for the first occurrence of a specified substring and returns the index of the first match.\u003c/p\u003e\n"],["\u003cp\u003eIf the substring is not found, the method returns -1.\u003c/p\u003e\n"],["\u003cp\u003eThe search performed by \u003ccode\u003eindex()\u003c/code\u003e is case-sensitive.\u003c/p\u003e\n"],["\u003cp\u003eThe method can be used in both JavaScript and Python environments within the Earth Engine platform.\u003c/p\u003e\n"],["\u003cp\u003eAn empty string pattern will return 0 as the index.\u003c/p\u003e\n"]]],["The `index` function searches a string (`target`) for a specified substring (`pattern`). It returns the integer index of the first matching substring's start position. If no match is found, it returns -1. The function is case-sensitive. An empty `pattern` will always return an index of 0. The provided examples illustrate the usage and expected return values.\n"],null,["Searches a string for the first occurrence of a substring. Returns the index of the first match, or -1.\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-------------------------|---------|\n| String.index`(pattern)` | Integer |\n\n| Argument | Type | Details |\n|----------------|--------|-----------------------|\n| this: `target` | String | The string to search. |\n| `pattern` | String | The string to find. |\n\nExamples\n\nCode Editor (JavaScript) \n\n```javascript\nprint(ee.String('abc123').index('')); // 0\nprint(ee.String('abc123').index('c1')); // 2\nprint(ee.String('abc123').index('ZZ')); // -1\n\n// index is case-sensitive.\nprint(ee.String('abc123').index('BC')); // -1\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\nColab (Python) \n\n```python\nprint(ee.String('abc123').index('').getInfo()) # 0\nprint(ee.String('abc123').index('c1').getInfo()) # 2\nprint(ee.String('abc123').index('ZZ').getInfo()) # -1\n\n# index is case-sensitive.\nprint(ee.String('abc123').index('BC').getInfo()) # -1\n```"]]