Cypher Right Function

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

Syntax: right(original, length)

Returns: A String.

Arguments

NameDescription
originalAn expression that returns a string.
lengthAn expression that returns a positive integer.

Example

RETURN right("Hello, World!", 5)

The value returned will be a string that contains the rightmost 4 characters of the string “Hello, World!”. Hence the returned string will be “orld!”.

Considerations

  • right(null, length) returns null.
  • right(null, null) returns 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 originaloriginal is returned.

Example

RETURN right("Cypher Tutorials!", 4)

Returns the following Result

right("Cypher Tutorials!", 4)
"als!"

Example

RETURN right("Cypher Tutorials!", 12)

Returns the following Result

right("Cypher Tutorials!", 12)
"r Tutorials!"

Example

RETURN right("Cypher Tutorials!", 18)

Returns the following Result

right("Cypher Tutorials!", 18)
"Cypher Tutorials!"

Note– If length exceeds the size of originaloriginal is returned.

Example

RETURN right("Cypher Tutorials!", -2)

Returns the following Result

right("Cypher Tutorials!", -2)
Error Neo.DatabaseError.General.UnknownError

Note– If length is not a positive integer, an Error is raised.

Example

RETURN right("Cypher Tutorials!", null)

Returns the following Result

right("Cypher Tutorials!", null)
Error Neo.ClientError.Statement.TypeError

Noteright(original, null) returns Error.

Example

RETURN right(null, 4)

Returns the following Result

right(null, 4)
null

Noteright(null, length) returns null.

Example

RETURN right(null, null)

Returns the following Result

right(null, null)
null

Noteright(null, null) returns null.

Learn More