Interface: String

Methods

lower

lower() returns rules.String

Returns a lowercase version of the input string.

Returns

non-null rules.String the lowercase string.

Example

'ABC'.lower() == 'abc'
'ABC123'.lower() == 'abc123'

matches

matches(re) returns rules.Boolean

Performs a regular expression match on the whole string.

Parameter

re

rules.String

A regular expression using Google RE2 syntax.

Value must not be null.

Returns

non-null rules.Boolean true if the whole string matches, false otherwise.

Example

'user@domain.com'.matches('.*@domain[.]com') == true
'banana'.matches('.*@domain[.]com') == false

replace

replace(re, sub) returns rules.String

Replaces all occurrences of substrings matching a regular expression with a user-supplied string.

Parameter

re

rules.String

A regular expression using Google RE2 syntax.

Value must not be null.

sub

rules.String

A string to substitute.

Value must not be null.

Returns

non-null rules.String A string representing the result of the replacement operation. If no substrings matched the regular expression, the unmodified original string is returned.

Example

'banana'.replace("a", "o") == 'bonono'
'banana'.replace("ana", "ee") == 'beena'
'foo@test.com'.replace(".", "-") == '---------------' // '.' regex match all

size

size() returns rules.Integer

Returns the number of characters in the string.

Returns

non-null rules.Integer the number of characters.

Example

'a'.size() == 1
'abc'.size() == 3

split

split(re) returns rules.List

Splits a string according to a regular expression.

Parameter

re

rules.String

A regular expression using Google RE2 syntax.

Value must not be null.

Returns

non-null rules.List a list of strings.

Example

'a/b/c'.split('/') == ['a', 'b', 'c']

toUtf8

toUtf8() returns rules.Bytes

Returns the UTF-8 byte encoding of a string.

Returns

non-null rules.Bytes a Bytes sequence containing the UTF-8 encoded representation of the string.

Example

'**'.toUtf8() == b'\x2A\x2A'
'€'.toUtf8() == b'\xE2\x82\xAC'

trim

trim() returns rules.String

Returns a version of the string with leading and trailing spaces removed.

Returns

non-null rules.String the trimmed string.

Example

' a '.trim() == 'a'
'b'.trim() == 'b'

upper

upper() returns rules.String

Returns an uppercase version of the input string.

Returns

non-null rules.String the uppercase string.

Example

'abc'.upper() == 'ABC'
'abc123'.upper() == 'ABC123'

Firebase gives you the tools and infrastructure you need to build better mobile and web apps, improve app quality, and grow your business.

Updated Dec 13, 2019

Use our flexible, extensible Firebase Security Rules to secure your data in Cloud Firestore, Firebase Realtime Database, and Cloud Storage.

Updated Mar 4, 2025