Splits a string on a regular expression, Returning a list of strings.
String.split(regex, flags)List
this: stringStringThe string to split.
regexStringA regular expression to split on. If regex is the empty string, then the input string is split into individual characters.
flagsString, default: ""A string specifying the regular expression flag: 'i' (ignore case)


Code Editor (JavaScript)

var s = ee.String('aBAbcD');
print(s.split('Ab')); // ["aB","cD"]
// 'i' tells split to ignore case.
print(s.split('ab', 'i')); // ["","","cD"]
// Split on 'b' or 'c'
print(s.split('[bc]', 'i')); // ["a","A","","D"]
// Split on 'BA' or 'c'
print(s.split('(BA|c)')); // ["a","b","D"]

var s = ee.String('a,b,cdee f,g');
// ["a",",","b",",","c","d","e","e"," ","f",",","g"]

print(s.split(' ')); // ["a,b,cdee","f,g"]
print(s.split('[[:space:]]')); // ["a,b,cdee","f,g"]

print(s.split(',')); // ["a","b","cdee f","g"]

print(s.split('ee')); // ["a,b,cd"," f,g"]

// Split on any lower case letter.
print(s.split('[a-z]')); // ["",",",",","","",""," ",","]

// ^ as the first character in [] excludes.
print(s.split('[^a-z]')); // ["a","b","cdee","f","g"]

// Splitting on characters that are special to split.
var s = ee.String('a.b*c?d');
print(s.split('\\.')); // ["a","b*c?d"]
print(s.split('[*]')); // ["a.b","c?d"]
print(s.split('[?]')); // ["a.b*c","d"]