ee.String.index

ค้นหาสตริงสำหรับสตริงย่อยที่เกิดขึ้นครั้งแรก แสดงดัชนีของการจับคู่แรก หรือ -1

การใช้งานการคืนสินค้า
String.index(pattern)จำนวนเต็ม
อาร์กิวเมนต์ประเภทรายละเอียด
ดังนี้ 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