# Cypher expressions

This page contains examples of allowed expressions in Cypher®.

## General

• A variable: `n`, `x`, `rel`, `myFancyVariable`, ``A name with special characters in it[]!``.

• A property: `n.prop`, `x.prop`, `rel.thisProperty`, `myFancyVariable.`(special property name)``.

• A dynamic property: `n["prop"]`, `rel[n.city + n.zip]`, `map[coll[0]]`.

• A parameter: `\$param`, `\$0`.

• A list of expressions: `['a', 'b']`, `[1, 2, 3]`, `['a', 2, n.property, \$param]`, `[]`.

• A function call: `length(p)`, `nodes(p)`.

• An aggregate function call: `avg(x.prop)`, `count(*)`.

• A path-pattern: `(a)-[r]->(b)`, `(a)-[r]-(b)`, `(a)--(b)`, `(a)-->()<--(b)`.

• An operator application: `1 + 2`, `3 < 4`.

• A subquery expression: `COUNT {}`, `COLLECT {}`, `EXISTS {}`, `CALL {}`.

• A regular expression: `a.name =~ 'Tim.*'`.

• A `CASE` expression.

• `null`.

 Expressions containing unsanitized user input may make your application vulnerable to Cypher injection. Consider using parameters instead. Learn more in Protecting against Cypher Injection.
 Most expressions in Cypher evaluate to `null` if any of their inner expressions are `null`. Notable exceptions are the operators `IS NULL`, `IS NOT NULL`, and the type predicate expressions.

## Numerical

• A numeric (`INTEGER` or `FLOAT`) literal: `13`, `-40000`, `3.14`.

• A numeric (`INTEGER` or `FLOAT`) literal in scientific notation: `6.022E23`.

• A hexadecimal `INTEGER` literal (starting with `0x`): `0x13af`, `0xFC3A9`, `-0x66eff`.

• An octal `INTEGER` literal (starting with `0o`): `0o1372`, `-0o5671`.

• A `FLOAT` literal: `Inf`, `Infinity`, `NaN`.

• `null`.

 Any numeric literal may contain an underscore `_` between digits. There may be an underscore between the `0x` or `0o` and the digits for hexadecimal and octal literals.

## String

• A `STRING` literal: `'Hello'`, `"World"`.

• A case-sensitive `STRING` matching expression: `a.surname STARTS WITH 'Sven'`, `a.surname ENDS WITH 'son'` or `a.surname CONTAINS 'son'`.

• `null`.

### String literal escape sequences

String literals can contain the following escape sequences:

Escape sequence Character

`\t`

Tab

`\b`

Backspace

`\n`

Newline

`\r`

Carriage return

`\f`

Form feed

`\'`

Single quote

`\"`

Double quote

`\\`

Backslash

`\uxxxx`

Unicode UTF-16 code point (4 hex digits must follow the `\u`)

## Boolean

• A `BOOLEAN` literal: `true`, `false`.

• A predicate expression (i.e. an expression returning a `BOOLEAN` value): `a.prop = 'Hello'`, `length(p) > 10`, `a.name IS NOT NULL`.

• Label and relationship type expressions: `(n:A|B)`, `()-[r:R1|R2]->()`.

• `null`.