text.join
Description
Joins an array of strings into a single string using a specified delimiter.
Syntax
flex.text.join(array, delimiter)
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
array |
list | Yes | The array of strings to join |
delimiter |
string | Yes | The separator to insert between elements |
Returns
Type: string
A single string with all array elements concatenated, separated by the delimiter. Returns null if the array is null or undefined.
Examples
Example 1: Basic String Joining
RETURN flex.text.join(['apple', 'banana', 'cherry'], ', ') AS result
Output:
result
----------------------
apple, banana, cherry
Example 2: Building CSV Lines
MATCH (u:User)
WITH [u.id, u.name, u.email] AS fields
RETURN flex.text.join(fields, ',') AS csvLine
Example 3: Creating Tags String
MATCH (p:Post)
RETURN p.title, flex.text.join(p.tags, ' #') AS hashtags
Output:
title | hashtags
----------------|------------------
My First Post | tech #coding #js
Example 4: Building Paths
WITH ['home', 'user', 'documents', 'file.txt'] AS parts
RETURN flex.text.join(parts, '/') AS path
Output:
path
--------------------------
home/user/documents/file.txt
Notes
- Returns
nullif input array isnull - Empty strings in the array are included in the output
- Delimiter can be any string, including empty string
- Commonly used for CSV generation, path building, or tag formatting
See Also
- text.format - Format strings with placeholders
- coll.zip - Combine two lists
Frequently Asked Questions 2
What happens if the array contains null elements?
Null elements are included in the output as empty positions between delimiters.
Can the delimiter be an empty string?
Yes. Using an empty string '' as the delimiter concatenates all elements without any separator.