ee.String.match

文字列を正規表現と照合します。一致する文字列のリストを返します。

用途戻り値
String.match(regex, flags)リスト
引数タイプ詳細
これ: input文字列検索する文字列。
regex文字列照合する正規表現。
flags文字列、デフォルト: ""正規表現フラグの組み合わせを指定する文字列。具体的には、'g'(グローバル マッチ)または 'i'(大文字と小文字を区別しない)の 1 つ以上。

コードエディタ(JavaScript)

var s = ee.String('ABCabc123');
print(s.match(''));  // ""
print(s.match('ab', 'g'));  // ab
print(s.match('ab', 'i'));  // AB
print(s.match('AB', 'ig')); // ["AB","ab"]
print(s.match('[a-z]+[0-9]+'));  // "abc123"
print(s.match('\\d{2}'));  // "12"

// Use [^] to match any character except a digit.
print(s.match('abc[^0-9]', 'i'));  // ["ABCa"]

Python の設定

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

import ee
import geemap.core as geemap

Colab(Python)

s = ee.String('ABCabc123')
print(s.match('').getInfo())  # ""
print(s.match('ab', 'g').getInfo())  # ab
print(s.match('ab', 'i').getInfo())  # AB
print(s.match('AB', 'ig').getInfo())  # ['AB','ab']
print(s.match('[a-z]+[0-9]+').getInfo())  # 'abc123'
print(s.match('\\d{2}').getInfo())  # '12'

# Use [^] to match any character except a digit.
print(s.match('abc[^0-9]', 'i').getInfo())  # ['ABCa']