UltipaDocs
Try Playground
  • Introduction
  • GQL vs Other Languages
    • Overview
    • Node and Edge Patterns
    • Path Patterns
    • Quantified Paths
    • Shortest Paths
    • Graph Patterns
    • Overview
    • Closed Graph
    • Open Graph
    • Graph Sharding and Storage
    • Constraints
    • Unique Identifiers
    • INSERT
    • INSERT OVERWRITE
    • UPSERT
    • 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
    • Scalar Functions
    • Path Functions
    • Aggregate Functions
    • Mathematical Functions
    • Trigonometric Functions
    • String Functions
    • List Functions
    • Datetime Functions
    • Spatial Functions
    • Type Conversion Functions
    • Table Functions
    • AI & Vector Functions
    • Database Functions
  • Operators
  • Predicates
  • Expressions
    • Index
    • Full-text Index
    • Vector Index
  • Transactions
  • Triggers
  • Query Management
    • Variables
    • Values and Types
    • Comments
    • Reserved Words
    • Syntactic Notation
  • GQL Conformance
  1. Docs
  2. /
  3. ISO GQL
  4. /
  5. Functions

String Functions

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:

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

Result:

newString
ABC34

char_length()

Returns the number of characters in a string.

NOTE

character_length() is a synonym to char_length().

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

Result:

char_length("Ultipa Graph")
12

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:

left("Ultipa Graph", 6)
Ultipa

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:

lower("Ultipa Graph")
ultipa graph

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:

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

Result:

newString
4ABC341

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') AS result

Result:

result
0

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:

result
hello graph

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:

right("Ultipa Graph", 5)
Graph

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:

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

Result:

newString
123ABC4

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:

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

Result:

username
appleLEE

substring()

Returns a substring of a given length from the given string, beginning with a 0-based index start.

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) AS subText

Result:

subText
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:

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

Result:

newString
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:

newString
Graph DB

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:

upper("Ultipa Graph")
ULTIPA GRAPH