ee.String.match

Compare une chaîne à une expression régulière. Renvoie une liste de chaînes correspondantes.

UtilisationRenvoie
String.match(regex, flags)Liste
ArgumentTypeDétails
ceci : inputChaîneChaîne dans laquelle effectuer la recherche.
regexChaîneExpression régulière à mettre en correspondance.
flagsChaîne, valeur par défaut : ""Chaîne spécifiant une combinaison d'indicateurs d'expression régulière, plus précisément un ou plusieurs des indicateurs suivants : "g" (correspondance globale) ou "i" (ignorer la casse).

Exemples

Éditeur de code (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"]

Configuration de Python

Consultez la page Environnement Python pour en savoir plus sur l'API Python et sur l'utilisation de geemap pour le développement interactif.

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']