Skip to main content

Split

Splits a string into an array of substrings using a separator.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.

Inputs

  • String - The string to split.
  • Separator - The delimiter to split by.

Options

This node does not have configurable options.

Output

  • Result - An array of strings containing all the split parts.

How It Works

The Split node divides a string into multiple parts based on a separator:

  • Splits at all occurrences of the separator
  • Separator is removed from the result
  • Empty parts are included (if separator appears consecutively)
  • Returns array - can be iterated or accessed by index
  • Empty separator splits into individual characters

Usage Examples

Example 1: Split CSV Line

  • String: "John,Doe,john@example.com"
  • Separator: ","
  • Result: ["John", "Doe", "john@example.com"]

Example 2: Split by Space

  • String: "Hello World Test"
  • Separator: " "
  • Result: ["Hello", "World", "Test"]

Example 3: Split Path

  • String: "/home/user/documents"
  • Separator: "/"
  • Result: ["", "home", "user", "documents"] (note empty first element)

Example 4: Split by New Line

  • String: "Line 1\nLine 2\nLine 3"
  • Separator: "\n"
  • Result: ["Line 1", "Line 2", "Line 3"]

Example 5: Split into Characters (Empty Separator)

  • String: "Hello"
  • Separator: ""
  • Result: ["H", "e", "l", "l", "o"]

Tips

  • Use for parsing delimited data (CSV, TSV, etc.)
  • Perfect for breaking down file paths
  • Great for processing multi-line text
  • Use with For Each loop to process each part
  • Access parts by index: ${msg.result[0]}, ${msg.result[1]}, etc.
  • Empty separator splits into individual characters
  • Consecutive separators create empty strings in array

Common Errors and Solutions

Error: Empty first/last elements in array

  • Cause: String starts/ends with separator
  • Solution: This is expected behavior. Filter empty elements if needed

Error: Need to split only at first occurrence

  • Cause: Split works on all occurrences
  • Solution: Use Cut node for first occurrence only

Error: Can't access array elements

  • Cause: Incorrect syntax
  • Solution: Use ${msg.result[0]} for first element, ${msg.result[1]} for second, etc.

Practical RPA Examples

Example: Parse CSV Data

String: "Product,Price,Quantity"
Separator: ","
Result: ["Product", "Price", "Quantity"]
Use: Extract CSV fields

Access:
- Field 1: ${msg.result[0]} = "Product"
- Field 2: ${msg.result[1]} = "Price"
- Field 3: ${msg.result[2]} = "Quantity"

Example: Parse Email Address

String: "user@example.com"
Separator: "@"
Result: ["user", "example.com"]
Use: Extract username and domain

Username: ${msg.result[0]}
Domain: ${msg.result[1]}

Example: Parse File Path

String: "/var/log/application/error.log"
Separator: "/"
Result: ["", "var", "log", "application", "error.log"]
Use: Navigate directory structure

Filename: ${msg.result[4]} = "error.log"

Example: Process Multi-Line Text

String: "Line 1\nLine 2\nLine 3"
Separator: "\n"
Result: ["Line 1", "Line 2", "Line 3"]
Use: Process each line separately

Example: Parse Query String

String: "name=John&age=30&city=NYC"
Separator: "&"
Result: ["name=John", "age=30", "city=NYC"]
Next: Split each by "=" to get key-value pairs

Example: Split Words for Analysis

String: "The quick brown fox"
Separator: " "
Result: ["The", "quick", "brown", "fox"]
Use: Word count, word analysis

Pattern: Nested Splitting

Parse complex delimited data:

String: "name:John,age:30,city:NYC"

Step 1: Split by "," → ["name:John", "age:30", "city:NYC"]
Step 2: For each item, split by ":" → [["name", "John"], ["age", "30"], ["city", "NYC"]]

Pattern: CSV Processing

Process CSV line:

Step 1: Split by "," → array of fields
Step 2: Trim each field (remove whitespace)
Step 3: Process each field value

Pattern: Parse Full Name

Split name into parts:

String: "John Michael Smith"
Split by " ": ["John", "Michael", "Smith"]

First Name: ${msg.result[0]}
Middle Name: ${msg.result[1]}
Last Name: ${msg.result[2]}

Working with Arrays

Access Elements

First element: ${msg.result[0]}
Second element: ${msg.result[1]}
Last element: ${msg.result[${msg.result.length - 1}]}

Count Elements

Array length: ${msg.result.length}
Use: Know how many parts were found

Iterate with For Each

Use For Each node to process each element:
For each item in ${msg.result}:
Process ${msg.item}

Handling Edge Cases

String Without Separator

String: "NoSeparatorHere"
Separator: ","
Result: ["NoSeparatorHere"]
Note: Array with single element

Empty String

String: ""
Separator: ","
Result: [""]
Note: Array with one empty string

Consecutive Separators

String: "a,,b"
Separator: ","
Result: ["a", "", "b"]
Note: Empty string in middle
  • Join - Opposite operation - join array into string
  • Cut - Split at first occurrence only
  • Replace - Replace separators before splitting
  • Trim - Clean strings before splitting