Returns the number of characters in a string. character_length() and length() are synonyms.
| Syntax | char_length(<str>) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The input string | |
| Return Type | UINT | ||
GQLRETURN char_length("Ultipa Graph")
Result: 12
Returns the number of bytes in a string. octet_length() is a synonym to byte_length().
| Syntax | byte_length(<str>) or octet_length(<str>) | ||
| Arguments | Name | Type | Description |
<str> | STRING | The input string | |
| Return Type | INT | ||
GQLRETURN byte_length("hello"), byte_length("你好")
Result:
| byte_length("hello") | byte_length("你好") |
|---|---|
| 5 | 6 |
Converts all the characters in a given string to lowercase.
| Syntax | lower(<str>) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
| Return Type | STRING | ||
GQLRETURN lower("Ultipa Graph")
Result: "ultipa graph"
Converts all the characters in a given string to uppercase.
| Syntax | upper(<str>) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
| Return Type | STRING | ||
GQLRETURN upper("Ultipa Graph")
Result: "ULTIPA GRAPH"
Returns a substring of the given string containing the specified number of leftmost characters.
| Syntax | left(<str>, <length>) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
<length> | UINT | Length of the substring | |
| Return Type | STRING | ||
GQLRETURN left("Ultipa Graph", 6)
Result: "Ultipa"
Returns a substring of the given string containing the specified number of rightmost characters.
| Syntax | right(<str>, <length>) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
<length> | UINT | Length of the substring | |
| Return Type | STRING | ||
GQLRETURN right("Ultipa Graph", 5)
Result: "Graph"
Returns a substring of a given length from the given string, beginning with a 0-based index start. substr() is a synonym to substring().
| Syntax | substring(<str>, <startIndex>, <length>) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
<startIndex> | Integer | The start position of the new string. | |
<length> | Integer | The length of the substring. | |
| Return Type | STRING | ||
GQLRETURN substring("crystal hawk river", 0, 7)
Result: "crystal"
Removes all the occurrences of the specified single character from either the leftmost, rightmost, or both ends of a given string.
| Syntax | trim([[<spec>] [<char>] FROM] <str>) | |||
| Arguments | Name | Type | Description | Note |
<spec> | / | The trim specification keyword:
| If FROM is specified, then at least one of <spec> and <char> shall be specified. | |
<char> | STRING | The character to look for; it defaults to a space | ||
<str> | Textual | The original string | / | |
| Return Type | STRING | |||
GQLRETURN trim(" Ultipa Graph ") AS newString
Result: "Ultipa Graph"
GQLRETURN trim(BOTH "a" FROM "aaGraph DBa") AS newString
Result: "Graph DB"
GQLRETURN trim(LEADING "a" FROM "aaGraph DBa") AS newString
Result:
| newString |
|---|
| Graph DBa |
GQLRETURN trim(TRAILING FROM " Graph DB ") AS newString
Result: " Graph DB"
Removes characters from the begining of a given string until encountering a character that is not contained in the specified set of characters.
| Syntax | ltrim(<str>[, <chars>]) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
<chars> | STRING | The set of characters to look for; it defaults to a space | |
| Return Type | STRING | ||
GQLRETURN ltrim(" Ultipa Graph ") AS newString
Result: "Ultipa Graph "
GQLRETURN ltrim("124ABC341", "123") AS newString
Result: "4ABC341"
Removes characters from the end of a given string until encountering a character that is not contained in the specified set of characters.
| Syntax | rtrim(<str>[, <chars>]) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
<chars> | STRING | The set of characters to look for; it defaults to a space | |
| Return Type | STRING | ||
GQLRETURN rtrim(" Ultipa Graph ") AS newString
Result: " Ultipa Graph"
GQLRETURN rtrim("123ABC4321", "123") AS newString
Result: "123ABC4"
Removes characters from both ends of a given string until encountering a character that is not contained in the specified set of characters.
| Syntax | btrim(<str>[, <chars>]) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
<chars> | STRING | The set of characters to look for; it defaults to a space | |
| Return Type | STRING | ||
GQLRETURN btrim(" Ultipa Graph ") AS newString
Result: "Ultipa Graph"
GQLRETURN btrim("123ABC341", "123") AS newString
Result: "ABC34"
Returns a string where all occurrences of a specified substring are replaced with another string.
| Syntax | replace(<str>, <find>, <replace>) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
<find> | Textual | The substring to search for within the original string. | |
<replace> | Textual | The new string that replaces each occurrence of the search string. | |
| Return Type | STRING | ||
GQLRETURN replace("hello world", "world", "graph") AS result
Result: "hello graph"
Returns a list of string resulting from the splitting of the given string around matches of the given delimiter.
| Syntax | split(<str>, <delimiter>) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
<delimiter> | Textual | The delimiter string with which to split the original string. | |
| Return Type | LIST<STRING> | ||
GQLRETURN split("apple,banana,grape", ",")
Result: ["apple","banana","grape"]
GQLRETURN split("[email protected]", "@")[0] AS username
Result: "appleLEE"
Returns true if a string contains the specified substring.
| Syntax | contains(<str>, <substring>) | ||
| Arguments | Name | Type | Description |
<str> | STRING | The input string | |
<substring> | STRING | The substring to search for | |
| Return Type | BOOL | ||
GQLRETURN contains("Graph Database", "Graph")
Result: true
Returns true if a string starts with the specified prefix.
| Syntax | starts_with(<str>, <prefix>) | ||
| Arguments | Name | Type | Description |
<str> | STRING | The input string | |
<prefix> | STRING | The prefix to check | |
| Return Type | BOOL | ||
GQLRETURN starts_with("Graph Database", "Graph")
Result: true
Returns true if a string ends with the specified suffix.
| Syntax | ends_with(<str>, <suffix>) | ||
| Arguments | Name | Type | Description |
<str> | STRING | The input string | |
<suffix> | STRING | The suffix to check | |
| Return Type | BOOL | ||
GQLRETURN ends_with("Graph Database", "Database")
Result: true
Converts a string into a consistent format based on the normalization form specified, in accordance with Unicode Standard Annex #15.
This function is typically used to compare two strings by their Unicode codepoints. Two characters appear identical to human eyes may have different codepoints, such as the multiplication sign × (U+00D7) and the letter x (U+0078).
| Syntax | normalize(<str>[, <form>]) | ||
| Arguments | Name | Type | Description |
<str> | Textual | The original string | |
<form> | / | The normalzation form (NF) keyword:
| |
| Return Type | STRING | ||
GQLRETURN normalize('×') = normalize('x')
Result: false
Encodes a string or bytes value to a hexadecimal string.
| Syntax | hex(<value>) | ||
| Arguments | Name | Type | Description |
<value> | STRING, BYTES | The input value | |
| Return Type | STRING | ||
GQLRETURN hex("hello")
Result: "68656c6c6f"
Decodes a hexadecimal string to bytes.
| Syntax | unhex(<hexStr>) | ||
| Arguments | Name | Type | Description |
<hexStr> | STRING | The hexadecimal string | |
| Return Type | STRING | ||
GQLRETURN unhex("68656c6c6f")
Result:
JSON{ "0": 104, "1": 101, "2": 108, "3": 108, "4": 111 }
Encodes a string to a Base64 string.
| Syntax | base64(<str>) | ||
| Arguments | Name | Type | Description |
<str> | STRING | The input string | |
| Return Type | STRING | ||
GQLRETURN base64("hello")
Result: "aGVsbG8="
Decodes a Base64 string to bytes.
| Syntax | unbase64(<base64Str>) | ||
| Arguments | Name | Type | Description |
<base64Str> | STRING | The Base64 encoded string | |
| Return Type | STRING | ||
GQLRETURN unbase64("aGVsbG8=")
Result:
JSON{ "0": 104, "1": 101, "2": 108, "3": 108, "4": 111 }