Stay organized with collections Save and categorize content based on your preferences.
Matches a string against a regular expression. Returns a list of matching strings.

String.match(regex, flags)List
this: inputStringThe string in which to search.
regexStringThe regular expression to match.
flagsString, default: ""A string specifying a combination of regular expression flags, specifically one or more of: 'g' (global match) or 'i' (ignore case)


Code Editor (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"]