String Functions Reference
Preview — Firestore in Native mode (with Pipeline Operations) for Enterprise Edition
This feature is subject to the "Pre-GA Offerings Terms" in the General Service Terms section of theService Specific Terms. You can process personal data for this feature as outlined in theCloud Data Processing Addendum, subject to the obligations and restrictions described in the agreement under which you access Google Cloud. Pre-GA features are available "as is" and might have limited support. For more information, see thelaunch stage descriptions.
String Functions
| Name | Description |
BYTE_LENGTH | Returns the number ofBYTES in aSTRING orBYTES value |
CHAR_LENGTH | Returns the number of unicode characters in aSTRING value |
STARTS_WITH | ReturnsTRUE if aSTRING begins with a given prefix |
ENDS_WITH | ReturnsTRUE if aSTRING ends with a given postfix |
LIKE | ReturnsTRUE if aSTRING matches a pattern |
REGEX_CONTAINS | ReturnsTRUE if a value is a partial or full match for a regular expression |
REGEX_MATCH | ReturnsTRUE if any part of a value matches a regular expression |
STRING_CONCAT | Concatenates multipleSTRING into aSTRING |
STRING_CONTAINS | ReturnsTRUE if a value contains aSTRING |
TO_UPPER | Converts aSTRING orBYTES value to uppercase. |
TO_LOWER | Converts aSTRING orBYTES value to lowercase. |
SUBSTRING | Gets a substring of aSTRING orBYTES value. |
STRING_REVERSE | Reverses aSTRING orBYTES value. |
TRIM | Trims leading and trailing characters from aSTRING orBYTES value. |
SPLIT | Splits aSTRING orBYTES value into an array. |
BYTE_LENGTH
Syntax:
byte_length[T <: STRING | BYTES](value: T) -> INT64Description:
Returns the number ofBYTES in aSTRING orBYTES value.
Examples:
| value | byte_length(value) |
|---|---|
| "abc" | 3 |
| "xyzabc" | 6 |
| b"abc" | 3 |
Node.js
constresult=awaitdb.pipeline().collection("books").select(field("title").byteLength().as("titleByteLength")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("books").select(field("title").byteLength().as("titleByteLength")));
Swift
letresult=tryawaitdb.pipeline().collection("books").select([Field("title").byteLength().as("titleByteLength")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("books").select(field("title").byteLength().alias("titleByteLength")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("books").select(field("title").byteLength().alias("titleByteLength")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").select(Field.of("title").byte_length().as_("titleByteLength")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").select(byteLength(field("title")).as("titleByteLength")).execute().get();
CHAR_LENGTH
Syntax:
char_length(value: STRING) -> INT64Description:
Returns the number of unicode code points inSTRING value.
Examples:
| value | char_length(value) |
|---|---|
| "abc" | 3 |
| "hello" | 5 |
| "world" | 5 |
Node.js
constresult=awaitdb.pipeline().collection("books").select(field("title").charLength().as("titleCharLength")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("books").select(field("title").charLength().as("titleCharLength")));
Swift
letresult=tryawaitdb.pipeline().collection("books").select([Field("title").charLength().as("titleCharLength")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("books").select(field("title").charLength().alias("titleCharLength")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("books").select(field("title").charLength().alias("titleCharLength")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").select(Field.of("title").char_length().as_("titleCharLength")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").select(charLength(field("title")).as("titleCharLength")).execute().get();
STARTS_WITH
Syntax:
starts_with(value: STRING, prefix: STRING) -> BOOLEANDescription:
ReturnsTRUE ifvalue begins withprefix.
Examples:
| value | prefix | starts_with(value, prefix) |
|---|---|---|
| "abc" | "a" | true |
| "abc" | "b" | false |
| "abc" | "" | true |
Node.js
constresult=awaitdb.pipeline().collection("books").select(field("title").startsWith("The").as("needsSpecialAlphabeticalSort")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("books").select(field("title").startsWith("The").as("needsSpecialAlphabeticalSort")));
Swift
letresult=tryawaitdb.pipeline().collection("books").select([Field("title").startsWith("The").as("needsSpecialAlphabeticalSort")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("books").select(field("title").startsWith("The").alias("needsSpecialAlphabeticalSort")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("books").select(field("title").startsWith("The").alias("needsSpecialAlphabeticalSort")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").select(Field.of("title").starts_with("The").as_("needsSpecialAlphabeticalSort")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").select(startsWith(field("title"),"The").as("needsSpecialAlphabeticalSort")).execute().get();
ENDS_WITH
Syntax:
ends_with(value: STRING, postfix: STRING) -> BOOLEANDescription:
ReturnsTRUE ifvalue ends withpostfix.
Examples:
| value | postfix | ends_with(value, postfix) |
|---|---|---|
| "abc" | "c" | true |
| "abc" | "b" | false |
| "abc" | "" | true |
Node.js
constresult=awaitdb.pipeline().collection("inventory/devices/laptops").select(field("name").endsWith("16 inch").as("16InLaptops")).execute();
Swift
letresult=tryawaitdb.pipeline().collection("inventory/devices/laptops").select([Field("name").endsWith("16 inch").as("16InLaptops")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("inventory/devices/laptops").select(field("name").endsWith("16 inch").alias("16InLaptops")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("inventory/devices/laptops").select(field("name").endsWith("16 inch").alias("16InLaptops")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("inventory/devices/laptops").select(Field.of("name").ends_with("16 inch").as_("16InLaptops")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("inventory/devices/laptops").select(endsWith(field("name"),"16 inch").as("16InLaptops")).execute().get();
LIKE
Syntax:
like(value: STRING, pattern: STRING) -> BOOLEANDescription:
ReturnsTRUE ifvalue matchespattern.
Examples:
| value | pattern | like(value, pattern) |
|---|---|---|
| "Firestore" | "Fire%" | true |
| "Firestore" | "%store" | true |
| "Datastore" | "Data_tore" | true |
| "100%" | "100\%" | true |
Node.js
constresult=awaitdb.pipeline().collection("books").select(field("genre").like("%Fiction").as("anyFiction")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("books").select(field("genre").like("%Fiction").as("anyFiction")));
Swift
letresult=tryawaitdb.pipeline().collection("books").select([Field("genre").like("%Fiction").as("anyFiction")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("books").select(field("genre").like("%Fiction").alias("anyFiction")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("books").select(field("genre").like("%Fiction").alias("anyFiction")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").select(Field.of("genre").like("%Fiction").as_("anyFiction")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").select(like(field("genre"),"%Fiction").as("anyFiction")).execute().get();
REGEX_CONTAINS
Syntax:
regex_contains(value: STRING, pattern: STRING) -> BOOLEANDescription:
ReturnsTRUE if some part ofvalue matchespattern. Ifpattern is not a valid regular expression, this function returns anerror.
Regular expressions follow the syntax of there2 library.
Examples:
| value | pattern | regex_contains(value, pattern) |
|---|---|---|
| "Firestore" | "Fire" | true |
| "Firestore" | "store$" | true |
| "Firestore" | "data" | false |
Node.js
constresult=awaitdb.pipeline().collection("documents").select(field("title").regexContains("Firestore (Enterprise|Standard)").as("isFirestoreRelated")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("documents").select(field("title").regexContains("Firestore (Enterprise|Standard)").as("isFirestoreRelated")));
Swift
letresult=tryawaitdb.pipeline().collection("documents").select([Field("title").regexContains("Firestore (Enterprise|Standard)").as("isFirestoreRelated")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("documents").select(field("title").regexContains("Firestore (Enterprise|Standard)").alias("isFirestoreRelated")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("documents").select(field("title").regexContains("Firestore (Enterprise|Standard)").alias("isFirestoreRelated")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("documents").select(Field.of("title").regex_contains("Firestore (Enterprise|Standard)").as_("isFirestoreRelated")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("documents").select(regexContains(field("title"),"Firestore (Enterprise|Standard)").as("isFirestoreRelated")).execute().get();
REGEX_MATCH
Syntax:
regex_match(value: STRING, pattern: STRING) -> BOOLEANDescription:
ReturnsTRUE ifvalue fully matchespattern. Ifpattern is not a valid regular expression, this function returns anerror.
Regular expressions follow the syntax of there2 library.
Examples:
| value | pattern | regex_match(value, pattern) |
|---|---|---|
| "Firestore" | "F.*store" | true |
| "Firestore" | "Fire" | false |
| "Firestore" | "^F.*e$" | true |
Node.js
constresult=awaitdb.pipeline().collection("documents").select(field("title").regexMatch("Firestore (Enterprise|Standard)").as("isFirestoreExactly")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("documents").select(field("title").regexMatch("Firestore (Enterprise|Standard)").as("isFirestoreExactly")));
Swift
letresult=tryawaitdb.pipeline().collection("documents").select([Field("title").regexMatch("Firestore (Enterprise|Standard)").as("isFirestoreExactly")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("documents").select(field("title").regexMatch("Firestore (Enterprise|Standard)").alias("isFirestoreExactly")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("documents").select(field("title").regexMatch("Firestore (Enterprise|Standard)").alias("isFirestoreExactly")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("documents").select(Field.of("title").regex_match("Firestore (Enterprise|Standard)").as_("isFirestoreExactly")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("documents").select(regexMatch(field("title"),"Firestore (Enterprise|Standard)").as("isFirestoreExactly")).execute().get();
STRING_CONCAT
Syntax:
string_concat(values: STRING...) -> STRINGDescription:
Concatenates two or moreSTRING values into a single result.
Examples:
| arguments | string_concat(values...) |
|---|---|
() | error |
("a") | "a" |
("abc", "def") | "abcdef" |
("a", "", "c") | "ac" |
Node.js
constresult=awaitdb.pipeline().collection("books").select(field("title").stringConcat(" by ",field("author")).as("fullyQualifiedTitle")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("books").select(field("title").stringConcat(" by ",field("author")).as("fullyQualifiedTitle")));
Swift
letresult=tryawaitdb.pipeline().collection("books").select([Field("title").concat([" by ",Field("author")]).as("fullyQualifiedTitle")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("books").select(field("title").concat(" by ",field("author")).alias("fullyQualifiedTitle")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("books").select(field("title").concat(" by ",field("author")).alias("fullyQualifiedTitle")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").select(Field.of("title").concat(" by ",Field.of("author")).as_("fullyQualifiedTitle")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").select(stringConcat(field("title")," by ",field("author")).as("fullyQualifiedTitle")).execute().get();
STRING_CONTAINS
Syntax:
string_contains(value: STRING, substring: STRING) -> BOOLEANDescription:
Checks ifvalue contains the literal Stringsubstring.
Examples:
| value | substring | string_contains(value, substring) |
|---|---|---|
| "abc" | "b" | true |
| "abc" | "d" | false |
| "abc" | "" | true |
| "a.c" | "." | true |
| "☃☃☃" | "☃" | true |
Node.js
constresult=awaitdb.pipeline().collection("articles").select(field("body").stringContains("Firestore").as("isFirestoreRelated")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("articles").select(field("body").stringContains("Firestore").as("isFirestoreRelated")));
Swift
letresult=tryawaitdb.pipeline().collection("articles").select([Field("body").stringContains("Firestore").as("isFirestoreRelated")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("articles").select(field("body").stringContains("Firestore").alias("isFirestoreRelated")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("articles").select(field("body").stringContains("Firestore").alias("isFirestoreRelated")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("articles").select(Field.of("body").string_contains("Firestore").as_("isFirestoreRelated")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("articles").select(stringContains(field("body"),"Firestore").as("isFirestoreRelated")).execute().get();
TO_UPPER
Syntax:
to_upper[T <: STRING | BYTES](value: T) -> TDescription:
Converts aSTRING orBYTES value to uppercase.
If a byte or char does not correspond to a UTF-8 lowercase alphabetic character, it is passed through unchanged.
Examples:
| value | to_upper(value) |
|---|---|
| "abc" | "ABC" |
| "AbC" | "ABC" |
| b"abc" | b"ABC" |
| b"a1c" | b"A1C" |
Node.js
constresult=awaitdb.pipeline().collection("authors").select(field("name").toUpper().as("uppercaseName")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("authors").select(field("name").toUpper().as("uppercaseName")));
Swift
letresult=tryawaitdb.pipeline().collection("authors").select([Field("name").toUpper().as("uppercaseName")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("authors").select(field("name").toUpper().alias("uppercaseName")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("authors").select(field("name").toUpper().alias("uppercaseName")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("authors").select(Field.of("name").to_upper().as_("uppercaseName")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("authors").select(toUpper(field("name")).as("uppercaseName")).execute().get();
TO_LOWER
Syntax:
to_lower[T <: STRING | BYTES](value: T) -> TDescription:
Converts aSTRING orBYTES value to lowercase.
If a byte or char does not correspond to a UTF-8 uppercase alphabetic character, it is passed through unchanged.
Examples:
| value | to_lower(value) |
|---|---|
| "ABC" | "abc" |
| "AbC" | "abc" |
| "A1C" | "a1c" |
| b"ABC" | b"abc" |
Node.js
constresult=awaitdb.pipeline().collection("authors").select(field("genre").toLower().equal("fantasy").as("isFantasy")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("authors").select(field("genre").toLower().equal("fantasy").as("isFantasy")));
Swift
letresult=tryawaitdb.pipeline().collection("authors").select([Field("genre").toLower().equal("fantasy").as("isFantasy")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("authors").select(field("genre").toLower().equal("fantasy").alias("isFantasy")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("authors").select(field("genre").toLower().equal("fantasy").alias("isFantasy")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("authors").select(Field.of("genre").to_lower().equal("fantasy").as_("isFantasy")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("authors").select(equal(toLower(field("genre")),"fantasy").as("isFantasy")).execute().get();
SUBSTRING
Syntax:
substring[T <: STRING | BYTES](input: T, position: INT64) -> Tsubstring[T <: STRING | BYTES](input: T, position: INT64, length: INT64) -> TDescription:
Returns a substring ofinput starting atposition (zero-based index) andincluding up tolength entries. If nolength is provided, returns the substringfromposition to the end of theinput.
If
inputis aSTRINGvalue,positionandlengthare measured in unicodecode points. If it is aBYTESvalue, they are measured in bytes.If
positionis greater than the length of theinput, an empty substring is returned. Ifpositionpluslengthis greater than the length ofinput, the substring is truncated to the end ofinput.If
positionis negative, the position is taken from the end of the input. If the negativepositionis greater than the size of the input, the position is set to zero.lengthmust be non-negative.
Examples:
Whenlength is not provided:
| input | position | substring(input, position) |
|---|---|---|
| "abc" | 0 | "abc" |
| "abc" | 1 | "bc" |
| "abc" | 3 | "" |
| "abc" | -1 | "c" |
| b"abc" | 1 | b"bc" |
Whenlength is provided:
| input | position | length | substring(input, position, length) |
|---|---|---|---|
| "abc" | 0 | 1 | "a" |
| "abc" | 1 | 2 | "bc" |
| "abc" | -1 | 1 | "c" |
| b"abc" | 0 | 1 | b"a" |
Node.js
constresult=awaitdb.pipeline().collection("books").where(field("title").startsWith("The ")).select(field("title").substring(4).as("titleWithoutLeadingThe")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("books").where(field("title").startsWith("The ")).select(field("title").substring(4).as("titleWithoutLeadingThe")));
Swift
letresult=tryawaitdb.pipeline().collection("books").where(Field("title").startsWith("The ")).select([Field("title").substring(position:4).as("titleWithoutLeadingThe")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("books").where(field("title").startsWith("The ")).select(field("title").substring(constant(4),field("title").charLength().subtract(4)).alias("titleWithoutLeadingThe")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("books").where(field("title").startsWith("The ")).select(field("title").substring(constant(4),field("title").charLength().subtract(4)).alias("titleWithoutLeadingThe")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").where(Field.of("title").starts_with("The ")).select(Field.of("title").substring(4).as_("titleWithoutLeadingThe")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").where(startsWith(field("title"),"The ")).select(substring(field("title"),constant(4),field("title").charLength()).as("titleWithoutLeadingThe")).execute().get();
STRING_REVERSE
Syntax:
string_reverse[T <: STRING | BYTES](input: T) -> TDescription:
Returns the supplied input in reverse order.
Characters are delineated by Unicode code points when the input is aSTRING, and bytes when the input is aBYTES value.
Examples:
| input | string_reverse(input) |
|---|---|
| "abc" | "cba" |
| "a🌹b" | "b🌹a" |
| "hello" | "olleh" |
| b"abc" | b"cba" |
Node.js
constresult=awaitdb.pipeline().collection("books").select(field("name").reverse().as("reversedName")).execute();
Web
constresult=awaitexecute(db.pipeline().collection("books").select(field("name").reverse().as("reversedName")));
Swift
letresult=tryawaitdb.pipeline().collection("books").select([Field("name").reverse().as("reversedName")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("books").select(field("name").reverse().alias("reversedName")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("books").select(field("name").reverse().alias("reversedName")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").select(Field.of("name").string_reverse().as_("reversedName")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").select(reverse(field("name")).as("reversedName")).execute().get();
TRIM
Syntax:
trim[T <: STRING | BYTES](input: T, values_to_trim: T) -> Ttrim[T <: STRING | BYTES](input: T) -> TDescription:
Trims a specified set ofBYTES orCHARS from the beginning and end of thesuppliedinput.
- If no
values_to_trimare provided, trims whitespace characters.
Examples:
Whenvalues_to_trim is not provided:
| input | trim(input) |
|---|---|
| " foo " | "foo" |
| b" foo " | b"foo" |
| "foo" | "foo" |
| "" | "" |
| " " | "" |
| "\t foo \n" | "foo" |
| b"\t foo \n" | b"foo" |
| "\r\f\v foo \r\f\v" | "foo" |
| b"\r\f\v foo \r\f\v" | b"foo" |
Whenvalues_to_trim is provided:
| input | values_to_trim | trim(input, values_to_trim) |
|---|---|---|
| "abcbfooaacb" | "abc" | "foo" |
| "abcdaabadbac" | "abc" | "daabad" |
| b"C1C2C3" | b"C1" | b"C2C3" |
| b"C1C2" | "foo" | error |
| "foo" | b"C1" | error |
Web
constresult=awaitexecute(db.pipeline().collection("books").select(field("name").trim().as("whitespaceTrimmedName")));
Swift
letresult=tryawaitdb.pipeline().collection("books").select([Field("name").trim("\n\t").as("whitespaceTrimmedName")]).execute()
Kotlin
Android
valresult=db.pipeline().collection("books").select(field("name").trim().alias("whitespaceTrimmedName")).execute()
Java
Android
Task<Pipeline.Snapshot>result=db.pipeline().collection("books").select(field("name").trim().alias("whitespaceTrimmedName")).execute();
Python
fromgoogle.cloud.firestore_v1.pipeline_expressionsimportFieldresult=(client.pipeline().collection("books").select(Field.of("name").trim().as_("whitespaceTrimmedName")).execute())
Java
Pipeline.Snapshotresult=firestore.pipeline().collection("books").select(trim(field("name")).as("whitespaceTrimmedName")).execute().get();
SPLIT
Syntax:
split(input: STRING) -> ARRAY<STRING>split[T <: STRING | BYTES](input: T, delimiter: T) -> ARRAY<T>Description:
Splits aSTRING orBYTES value, using a delimiter.
For
STRINGthe default delimiter is the comma,. The delimiter is treated as a single string.For
BYTES, you must specify a delimiter.Splitting on an empty delimiter produces an array of Unicode codepoints for
STRINGvalues, and an array ofBYTESforBYTESvalues.Splitting an empty
STRINGreturns anARRAYwith a single emptySTRING.
Examples:
Whendelimiter is not provided:
| input | split(input) |
|---|---|
| "foo,bar,foo" | ["foo", "bar", "foo"] |
| "foo" | ["foo"] |
| ",foo," | ["", "foo", ""] |
| "" | [""] |
| b"C120C2C4" | error |
Whendelimiter is provided:
| input | delimiter | split(input, delimiter) |
|---|---|---|
| "foo bar foo" | " " | ["foo", "bar", "foo"] |
| "foo bar foo" | "z" | ["foo bar foo"] |
| "abc" | "" | ["a", "b", "c"] |
| b"C1,C2,C4" | b"," | [b"C1", b"C2", b"C4"] |
| b"ABC" | b"" | [b"A", b"B", b"C"] |
| "foo" | b"C1" | error |
What's next
- See thePipeline Queries overview
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-18 UTC.