Cypher Left Function

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

Syntax: left(original, length)

Returns: A String.

Arguments

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

Example

RETURN left("Hello, World!", 4)

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

Considerations

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

Example

RETURN left("Cypher Tutorials!", 4)

Returns the following Result

left("Cypher Tutorials!", 4)
"Cyph"

Example

RETURN left("Cypher Tutorials!", 8)

Returns the following Result

left("Cypher Tutorials!", 8)
"Cypher T"

Example

RETURN left("Cypher Tutorials!", 18)

Returns the following Result

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

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

Example

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

Returns the following Result

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

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

Example

RETURN left("Cypher Tutorials!", null)

Returns the following Result

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

Noteleft(original, null) returns Error.

Example

RETURN left(null, 4)

Returns the following Result

left(null, 4)
null

Noteleft(null, length) returns null.

Example

RETURN left(null, null)

Returns the following Result

left(null, null)
null

Noteleft(null, null) returns null.

Learn More