String Functions
String Functions
These functions can be used when working with and manipulating text and string values.
Function | Description |
---|---|
string::concat() | Concatenates strings together |
string::contains() | Check whether a string contains another string |
string::endsWith() | Checks whether a string ends with another string |
string::join() | Joins strings together with a delimiter |
string::len() | Returns the length of a string |
string::lowercase() | Converts a string to lowercase |
string::repeat() | Repeats a string a number of times |
string::replace() | Replaces an occurrence of a string with another string |
string::reverse() | Reverses a string |
string::slice() | Extracts and returns a section of a string |
string::slug() | Converts a string into human and URL-friendly string |
string::split() | Divides a string into an ordered list of substrings |
string::startsWith() | Checks whether a string starts with another string |
string::trim() | Removes whitespace from the start and end of a string |
string::uppercase() | Converts a string to uppercase |
string::words() | Splits a string into an array of separate words |
string::is::alphanum() | Checks whether a value has only alphanumeric characters |
string::is::alpha() | Checks whether a value has only alpha characters |
string::is::ascii() | Checks whether a value has only ascii characters |
string::is::format() | Checks whether a value matches a format format |
string::is::domain() | Checks whether a value is a domain |
string::is::email() | Checks whether a value is an email |
string::is::hexadecimal() | Checks whether a value is hexadecimal |
string::is::latitude() | Checks whether a value is a latitude value |
string::is::longitude() | Checks whether a value is a longitude value |
string::is::numeric() | Checks whether a value has only numeric characters |
string::is::semver() | Checks whether a value matches a semver version |
string::is::url() | Checks whether a value is a valid URL |
string::is::uuid() | Checks whether a value is a UUID |
string::concat
The string::concat
function concatenates strings together.
string::concat(string...) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::concat('this', ' ', 'is', ' ', 'a', ' ', 'test');
"this is a test"
string::contains
The string::contains
function checks whether a string contains another string.
string::contains(string, string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::contains('abcdefg', 'cde');
true
string::endsWith
The string::endsWith
function checks whether a string ends with another string.
string::endsWith(string, string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::endsWith('some test', 'test');
true
string::join
The string::join
function joins strings together with a delimiter.
string::join(string, string...) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::join(', ', 'a', 'list', 'of', 'items');
"a, list, of, items"
string::len
The string::len
function returns the length of a given string.
string::len(string) -> number
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::len('this is a test');
14
string::lowercase
The string::lowercase
function converts a string to lowercase.
string::lowercase(string) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::lowercase('THIS IS A TEST');
"this is a test"
string::repeat
The string::repeat
function repeats a string a number of times.
string::repeat(string, number) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::repeat('test', 3);
"testtesttest"
string::replace
The string::replace
function replaces an occurrence of a string with another string.
string::replace(string, string, string) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::replace('this is a test', 'a test', 'awesome');
"this is awesome"
string::reverse
The string::reverse
function reverses a string.
string::reverse(string) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::reverse('this is a test');
"tset a si siht"
string::slice
The string::slice
function reverses a string.
string::slice(string, number, number) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::slice('this is a test', 10, 4);
"test"
string::slug
The string::slug
function converts a string into a human and URL-friendly string.
string::slug(string) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::slug('SurrealDB has launched #database #awesome');
"surrealdb-has-launched-database-awesome"
string::split
The string::split
function splits a string by a given delimiter.
string::split(string, string) -> array
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::split('this, is, a, list', ', ');
["this", "is", "a", "list"]
string::startsWith
The string::startsWith
function checks whether a string starts with another string.
string::startsWith(string, string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::startsWith('some test', 'some');
true
string::trim
The string::trim
function removes whitespace from the start and end of a string.
string::trim(string) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::trim(' this is a test ');
"this is a test"
string::uppercase
The string::uppercase
function converts a string to uppercase.
string::uppercase(string) -> string
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::uppercase('this is a test');
"THIS IS A TEST"
string::words
The string::words
function splits a string into an array of separate words.
string::words(string) -> array
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::words('this is a test');
["this", "is", "a", "test"]
string::is::alphanum
The string::is::alphanum
function checks whether a value has only alphanumeric characters.
string::is::alphanum(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::alphanum("ABC123");
true
string::is::alpha
The string::is::alpha
function checks whether a value has only alpha characters.
string::is::alpha(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::alpha("ABCDEF");
true
string::is::ascii
The string::is::ascii
function checks whether a value has only ascii characters.
string::is::ascii(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::ascii("ABC123");
true
string::is::format
The string::is::format
function checks whether a value matches a specified format.
string::is::format(string, string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::format("2015-09-05 23:56:04", "%Y-%m-%d %H:%M:%S");
true
string::is::domain
The string::is::domain
function checks whether a value is a domain.
string::is::domain(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::domain("surrealdb.com");
true
string::is::email
The string::is::email
function checks whether a value is an email.
string::is::email(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::email("info@surrealdb.com");
true
string::is::hexadecimal
The string::is::hexadecimal
function checks whether a value is hexadecimal.
string::is::hexadecimal(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::hexadecimal("ff009e");
true
string::is::latitude
The string::is::latitude
function checks whether a value is a latitude value.
string::is::latitude(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::latitude("-0.118092");
true
string::is::longitude
The string::is::longitude
function checks whether a value is a longitude value.
string::is::longitude(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::longitude("51.509865");
true
string::is::numeric
The string::is::numeric
function checks whether a value has only numeric characters.
string::is::numeric(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::numeric("1484091748");
true
string::is::semver
The string::is::semver
function checks whether a value matches a semver version.
string::is::semver(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::semver("1.0.0");
true
string::is::url
The string::is::url
function checks whether a value is a valid URL.
string::is::url(string) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN string::is::url("https://surrealdb.com");
true
string::is::uuid
The string::is::uuid
function checks whether a value is a UUID.
type::is::uuid(any) -> bool
The following example shows this function, and its output, when used in a RETURN
statement:
RETURN type::is::uuid("018a6680-bef9-701b-9025-e1754f296a0f");
true