left()
returns a string containing the specified number of leftmost characters of the original string.
Syntax: left(original, length)
Returns: A String.
Arguments
Name | Description |
original | An expression that returns a string. |
length | An 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)
returnsnull
.left(null, null)
returnsnull
.left(original, null)
will raise an error.- If
length
is not a positive integer, an error is raised. - If
length
exceeds the size oforiginal
,original
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 original
, original
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 |
Note– left(original, null)
returns Error
.
Example
RETURN left(null, 4)
Returns the following Result
left(null, 4) |
null |
Note– left(null, length)
returns null
.
Example
RETURN left(null, null)
Returns the following Result
left(null, null) |
null |
Note– left(null, null)
returns null
.