apoc.text.random

Function APOC Core

apoc.text.random(length, valid) YIELD value - generate a random string

Signature

apoc.text.random(length :: INTEGER?, valid = A-Za-z0-9 :: STRING?) :: (STRING?)

Input parameters

Name Type Default

length

INTEGER?

null

valid

STRING?

A-Za-z0-9

Usage Examples

You can generate a random string to a specified length by calling apoc.text.random with a length parameter and optional string of valid characters.

The valid parameter will accept the following regex patterns, alternatively you can provide a string of letters and/or characters.

Pattern

Description

A-Z

A-Z in uppercase

a-z

A-Z in lowercase

0-9

Numbers 0-9 inclusive

The following call will return a random string including uppercase letters, numbers and . and $ characters.

RETURN apoc.text.random(10, "A-Z0-9.$") AS output;
Table 1. Results
output

"V9Y7N54LO6"