replace

replace() returns a string in which all occurrences of a specified string in the original string have been replaced by another (specified) string.

Syntax: replace(original, search, replace)

Returns:

  1. An agtype string.

Arguments:

Name Description
original An expression that returns a string.
search An expression that specifies the string to be replaced in original.
replace An expression that specifies the replacementstring.

Considerations:

  • If any argument is null, null will be returned.
  • If search is not found in original, original will be returned.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN replace('hello', 'l', 'w')
  4. $$) as (str_array agtype);

Result:

new_str
“Hewwo”
1 row(s) returned

split

split() returns a list of strings resulting from the splitting of the original string around matches of the given delimiter.

Syntax: split(original, split_delimiter)

Returns:

  1. An agtype list of agtype strings.

Arguments:

Name Description
original An expression that returns a string.
split_delimiter The string with which to split original.

Considerations:

  • split(null, splitDelimiter) and split(original, null) both return null

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN split('one,two', ',')
  4. $$) as (split_list agtype);

Result:

split_list
[“one”,”two”]
1 row(s) returned

left

left() returns a string containing the specified number of leftmost characters of the original string.

Syntax: left(original, length)

Returns:

  1. An agtype string.

Arguments:

Name Description
original An expression that returns a string.
n An expression that returns a positive integer.

Considerations:

  • left(null, length) and left(null, null) both return null
  • left(original, null) will raise an error.
  • If length is not a positive integer, an error is raised.
  • If length exceeds the size of original, original is returned.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN left('Hello', 3)
  4. $$) as (new_str agtype);

Result:

new_str
“Hel”
1 row(s) returned

right

right() returns a string containing the specified number of rightmost characters of the original string.

Syntax: right(original, length)

Returns:

  1. An agtype string.

Arguments:

Name Description
original An expression that returns a string.
n An expression that returns a positive integer.

Considerations:

  • right(null, length) and right(null, null) both return null
  • right(original, null) will raise an error.
  • If length is not a positive integer, an error is raised.
  • If length exceeds the size of original, original is returned.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN right('hello', 3)
  4. $$) as (new_str agtype);

Result:

new_str
“llo”
1 row(s) returned

substring

substring() returns a substring of the original string, beginning with a 0-based index start and length.

Syntax: substring(original, start [, length])

Returns:

  1. An agtype string.

Arguments:

Name Description
original An expression that returns a string.
start An expression denoting the position at which the substring will begin.
length An optional expression that returns a positive integer, denoting how many characters of the original expression will be returned.

Considerations:

  • start uses a zero-based index.
  • If length is omitted, the function returns the substring starting at the position given by start and extending to the end of original.
  • If original is null, null is returned.
  • If either start or length is null or a negative integer, an error is raised.
  • If start is 0, the substring will start at the beginning of original.
  • If length is 0, the empty string will be returned.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN substring('hello', 1, 3), substring('hello', 2)
  4. $$) as (sub_str1 agtype, sub_str2 agtype);

Result:

sub_str1 sub_str2
‘ell’ ‘llo’
1 row(s) returned

rTrim

rTrim() returns the original string with trailing whitespace removed.

Syntax: rTrim(original)

Returns:

  1. An agtype string.

Arguments:

Name Description
original An expression that returns a string

Considerations:

  • rTrim(null) returns null

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN rTrim(' hello ')
  4. $$) as (right_trimmed_str agtype);

Result:

right_trimmed_str
“ hello”
1 row(s) returned

lTrim

lTrim() returns the original string with leading whitespace removed.

Syntax: lTrim(original)

Returns:

  1. An agtype string.

Arguments:

Name Description
original An expression that returns a string

Considerations:

  • lTrim(null) returns null

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN lTrim(' hello ')
  4. $$) as (left_trimmed_str agtype);

Result:

left_trimmed_str
“hello ”
1 row(s) returned

trim

trim() returns the original string with leading and trailing whitespace removed.

Syntax: trim(original)

Returns:

  1. An agtype string.

Arguments:

Name Description
original An expression that returns a string

Considerations:

  • trim(null) returns null

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN trim(' hello ')
  4. $$) as (trimmed_str agtype);

Result:

trimmed_str
“hello”
1 row(s) returned

toLower

toLower() returns the original string in lowercase.

Syntax: toLower(original)

Returns:

  1. An agtype string.

Arguments:

Name Description
original An expression that returns a string

Considerations:

  • toLower(null) returns null

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN toLower('HELLO')
  4. $$) as (lower_str agtype);

Result:

lower_str
“hello”
1 row(s) returned

toUpper

toUpper()returns the original string in uppercase.

Syntax: toUpper(original)

Returns:

  1. An agtype string.

Arguments:

Name Description
original An expression that returns a string

Considerations:

  • toUpper(null) returns null

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN toUpper('hello')
  4. $$) as (upper_str agtype);

Result:

upper_str
“HELLO”
1 row(s) returned

reverse

reverse() returns a string in which the order of all characters in the original string have been reversed.

Syntax: reverse(original)

Returns:

  1. An agtype string.

Arguments:

Name Description
original An expression that returns a string

Considerations:

  • reverse(null) returns null.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN reverse("hello")
  4. $$) as (reverse_str agtype);

Result:

reverse_str
“olleh”
1 row(s) returned

toString

toString() converts an integer, float or boolean value to a string.

Syntax: toString(expression)

Returns:

  1. A string.

Arguments:

Name Description
expression An expression that returns a number, a boolean, or a string.

Considerations:

  • toString(null) returns null
  • If expression is a string, it will be returned unchanged.

Query:

  1. SELECT *
  2. FROM cypher('graph_name', $$
  3. RETURN toString(11.5),toString('a string'), toString(true)
  4. $$) as (float_to_str agtype, str_to_str agtype, bool_to_string);

Result:

float_to_str str_to_str bool_to_str
“11.5” “a string” “true”
1 row(s) returned