UltipaDocs
Products
Solutions
Resources
Company
Start Free Trial
UltipaDocs
Start Free Trial
  • Introduction
  • GQL vs Other Languages
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Questioned Paths
    • Shortest Paths
    • Graph Patterns
    • Overview
    • Open Graph
    • Closed Graph
    • Constraints
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • SET
    • REMOVE
    • DELETE
    • Query Composition
    • Result Table and Visualization
    • MATCH
    • OPTIONAL MATCH
    • FILTER
    • LET
    • FOR
    • ORDER BY
    • LIMIT
    • SKIP
    • CALL
    • RETURN
    • Composite Query
    • NEXT
    • All Functions
    • Element Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Null Functions
    • Utility Functions
    • Type Conversion Functions
    • Table Functions
    • AI & Vector Functions
    • Database Functions
  • Operators
  • Predicates
    • CASE
    • LET Value Expression
    • Value Query Expression
    • List Comprehension
    • Index
    • Full-text Index
    • Vector Index
  • Transactions
  • Triggers
  • Query Management
  • Backup and Restore
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Syntactic Notation
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Functions

String Functions

char_length()

Returns the number of characters in a string. character_length() and length() are synonyms.

Syntaxchar_length(<str>)
ArgumentsNameTypeDescription
<str>TextualThe input string
Return TypeUINT
GQL
RETURN char_length("Ultipa Graph")

Result: 12

byte_length()

Returns the number of bytes in a string. octet_length() is a synonym to byte_length().

Syntaxbyte_length(<str>) or octet_length(<str>)
ArgumentsNameTypeDescription
<str>STRINGThe input string
Return TypeINT
GQL
RETURN byte_length("hello"), byte_length("你好")

Result:

byte_length("hello")byte_length("你好")
56

lower()

Converts all the characters in a given string to lowercase.

Syntaxlower(<str>)
ArgumentsNameTypeDescription
<str>TextualThe original string
Return TypeSTRING
GQL
RETURN lower("Ultipa Graph")

Result: "ultipa graph"

upper()

Converts all the characters in a given string to uppercase.

Syntaxupper(<str>)
ArgumentsNameTypeDescription
<str>TextualThe original string
Return TypeSTRING
GQL
RETURN upper("Ultipa Graph")

Result: "ULTIPA GRAPH"

left()

Returns a substring of the given string containing the specified number of leftmost characters.

Syntaxleft(<str>, <length>)
ArgumentsNameTypeDescription
<str>TextualThe original string
<length>UINTLength of the substring
Return TypeSTRING
GQL
RETURN left("Ultipa Graph", 6)

Result: "Ultipa"

right()

Returns a substring of the given string containing the specified number of rightmost characters.

Syntaxright(<str>, <length>)
ArgumentsNameTypeDescription
<str>TextualThe original string
<length>UINTLength of the substring
Return TypeSTRING
GQL
RETURN right("Ultipa Graph", 5)

Result: "Graph"

substring()

Returns a substring of a given length from the given string, beginning with a 0-based index start. substr() is a synonym to substring().

Syntaxsubstring(<str>, <startIndex>, <length>)
ArgumentsNameTypeDescription
<str>TextualThe original string
<startIndex>IntegerThe start position of the new string.
<length>IntegerThe length of the substring.
Return TypeSTRING
GQL
RETURN substring("crystal hawk river", 0, 7)

Result: "crystal"

trim()

Removes all the occurrences of the specified single character from either the leftmost, rightmost, or both ends of a given string.

Syntaxtrim([[<spec>] [<char>] FROM] <str>)
ArgumentsNameTypeDescriptionNote
<spec>/The trim specification keyword:
  • BOTH (default) removes every leading and trailing character equals to <char> from <str>
  • LEADING removes every leading character equals to <char> from <str>
  • TRAILING removes every trailing character equals to <char> from <str>
If FROM is specified, then at least one of <spec> and <char> shall be specified.
<char>STRINGThe character to look for; it defaults to a space
<str>TextualThe original string/
Return TypeSTRING
GQL
RETURN trim("  Ultipa Graph   ") AS newString

Result: "Ultipa Graph"

GQL
RETURN trim(BOTH "a" FROM "aaGraph DBa") AS newString

Result: "Graph DB"

GQL
RETURN trim(LEADING "a" FROM "aaGraph DBa") AS newString

Result:

newString
Graph DBa
GQL
RETURN trim(TRAILING FROM "  Graph DB   ") AS newString

Result: " Graph DB"

ltrim()

Removes characters from the begining of a given string until encountering a character that is not contained in the specified set of characters.

Syntaxltrim(<str>[, <chars>])
ArgumentsNameTypeDescription
<str>TextualThe original string
<chars>STRINGThe set of characters to look for; it defaults to a space
Return TypeSTRING
GQL
RETURN ltrim("  Ultipa Graph   ") AS newString

Result: "Ultipa Graph "

GQL
RETURN ltrim("124ABC341", "123") AS newString

Result: "4ABC341"

rtrim()

Removes characters from the end of a given string until encountering a character that is not contained in the specified set of characters.

Syntaxrtrim(<str>[, <chars>])
ArgumentsNameTypeDescription
<str>TextualThe original string
<chars>STRINGThe set of characters to look for; it defaults to a space
Return TypeSTRING
GQL
RETURN rtrim("  Ultipa Graph   ") AS newString

Result: " Ultipa Graph"

GQL
RETURN rtrim("123ABC4321", "123") AS newString

Result: "123ABC4"

btrim()

Removes characters from both ends of a given string until encountering a character that is not contained in the specified set of characters.

Syntaxbtrim(<str>[, <chars>])
ArgumentsNameTypeDescription
<str>TextualThe original string
<chars>STRINGThe set of characters to look for; it defaults to a space
Return TypeSTRING
GQL
RETURN btrim("  Ultipa Graph   ") AS newString

Result: "Ultipa Graph"

GQL
RETURN btrim("123ABC341", "123") AS newString

Result: "ABC34"

replace()

Returns a string where all occurrences of a specified substring are replaced with another string.

Syntaxreplace(<str>, <find>, <replace>)
ArgumentsNameTypeDescription
<str>TextualThe original string
<find>TextualThe substring to search for within the original string.
<replace>TextualThe new string that replaces each occurrence of the search string.
Return TypeSTRING
GQL
RETURN replace("hello world", "world", "graph") AS result

Result: "hello graph"

split()

Returns a list of string resulting from the splitting of the given string around matches of the given delimiter.

Syntaxsplit(<str>, <delimiter>)
ArgumentsNameTypeDescription
<str>TextualThe original string
<delimiter>TextualThe delimiter string with which to split the original string.
Return TypeLIST<STRING>
GQL
RETURN split("apple,banana,grape", ",")

Result: ["apple","banana","grape"]

GQL
RETURN split("[email protected]", "@")[0] AS username

Result: "appleLEE"

contains()

Returns true if a string contains the specified substring.

Syntaxcontains(<str>, <substring>)
ArgumentsNameTypeDescription
<str>STRINGThe input string
<substring>STRINGThe substring to search for
Return TypeBOOL
GQL
RETURN contains("Graph Database", "Graph")

Result: true

starts_with()

Returns true if a string starts with the specified prefix.

Syntaxstarts_with(<str>, <prefix>)
ArgumentsNameTypeDescription
<str>STRINGThe input string
<prefix>STRINGThe prefix to check
Return TypeBOOL
GQL
RETURN starts_with("Graph Database", "Graph")

Result: true

ends_with()

Returns true if a string ends with the specified suffix.

Syntaxends_with(<str>, <suffix>)
ArgumentsNameTypeDescription
<str>STRINGThe input string
<suffix>STRINGThe suffix to check
Return TypeBOOL
GQL
RETURN ends_with("Graph Database", "Database")

Result: true

normalize()

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).

Syntaxnormalize(<str>[, <form>])
ArgumentsNameTypeDescription
<str>TextualThe original string
<form>/The normalzation form (NF) keyword:
  • NFC (default): Canonical Composition. Characters are composed into their most composed forms. E.g., Å (U+00C5) as a single character.
  • NFD: Canonical Decomposition. Characters are decomposed into their constituent parts. E.g., Å (U+00C5) becomes A (U+0041) + ◌̊ (U+030A).
  • NFKC: Similar to NFC but also replaces compatibility characters with their canonical equivalents. E.g., 2⁵ (U+0032 U+2075) becomes 25 (U+0032 U+0035).
  • NFKD: Similar to NFD but also replaces compatibility characters with their canonical equivalents. E.g., 2⁵ (U+0032 U+2075) becomes 25 (U+0032 U+0035).
Return TypeSTRING
GQL
RETURN normalize('×') = normalize('x')

Result: false

hex()

Encodes a string or bytes value to a hexadecimal string.

Syntaxhex(<value>)
ArgumentsNameTypeDescription
<value>STRING, BYTESThe input value
Return TypeSTRING
GQL
RETURN hex("hello")

Result: "68656c6c6f"

unhex()

Decodes a hexadecimal string to bytes.

Syntaxunhex(<hexStr>)
ArgumentsNameTypeDescription
<hexStr>STRINGThe hexadecimal string
Return TypeSTRING
GQL
RETURN unhex("68656c6c6f")

Result:

JSON
{
  "0": 104,
  "1": 101,
  "2": 108,
  "3": 108,
  "4": 111
}

base64()

Encodes a string to a Base64 string.

Syntaxbase64(<str>)
ArgumentsNameTypeDescription
<str>STRINGThe input string
Return TypeSTRING
GQL
RETURN base64("hello")

Result: "aGVsbG8="

unbase64()

Decodes a Base64 string to bytes.

Syntaxunbase64(<base64Str>)
ArgumentsNameTypeDescription
<base64Str>STRINGThe Base64 encoded string
Return TypeSTRING
GQL
RETURN unbase64("aGVsbG8=")

Result:

JSON
{
  "0": 104,
  "1": 101,
  "2": 108,
  "3": 108,
  "4": 111
}