ee.String.index

文字列内で部分文字列が最初に出現する位置を検索します。最初の一致のインデックスを返します。一致がない場合は -1 を返します。

用途戻り値
String.index(pattern)Integer
引数タイプ詳細
これ: target文字列検索する文字列。
pattern文字列検索する文字列。

コードエディタ(JavaScript)

print(ee.String('abc123').index(''));  // 0
print(ee.String('abc123').index('c1'));  // 2
print(ee.String('abc123').index('ZZ'));  // -1

// index is case-sensitive.
print(ee.String('abc123').index('BC'));  // -1

Python の設定

Python API とインタラクティブな開発での geemap の使用については、 Python 環境のページをご覧ください。

import ee
import geemap.core as geemap

Colab(Python)

print(ee.String('abc123').index('').getInfo())  # 0
print(ee.String('abc123').index('c1').getInfo())  # 2
print(ee.String('abc123').index('ZZ').getInfo())  # -1

# index is case-sensitive.
print(ee.String('abc123').index('BC').getInfo())  # -1