Skip to main content

Split Text Node

Split Text Node Screenshot

Overview

The Split Text Node is used to split a string into an array of substrings based on a specified delimiter. This is useful when you want to separate a string into individual elements for further processing.

The node allows you to specify the delimiter either directly in the node settings or dynamically via an input port. The delimiter can be any string, including special characters like newline (\n), tab (\t), and space ( ).

When entering special characters such as a new line in the node settings, put the literal character, not the escape sequence. For example, to split a string by a new line, press the Enter key to insert a new line in the node settings.

Inputs

TitleData TypeDescriptionDefault ValueNotes
StringstringThe string that should be split.(required)The input will be coerced into a string if it is not a string.
DelimiterstringThe delimiter to split the string by. This input is only available if Use Delimiter Input is enabled.(empty)The input will be coerced into a string if it is not a string.

Example 1: Split a string into words

  1. Create a Text Node and set the value to Hello, world!.
  2. Create a Split Text Node and set the Delimiter to ,.
  3. Connect the Text Node to the String input of the Split Text Node.
  4. Run the graph. The Split output of the Split Text Node should contain the array ["Hello", " world!"].

Split Text Node Example 1

Example 2: Split a string into lines

  1. Create a Text Node and set the value to:

    Hello,
    world!
  2. Create a Split Text Node and set the Delimiter to \n.

  3. Connect the Text Node to the String input of the Split Text Node.

  4. Run the graph. The Split output of the Split Text Node should contain the array ["Hello,", "world!"].

Split Text Node Example 2

Error Handling

The Split Text Node will error if the String input is not provided. If the Delimiter input or setting is not provided, the node will not split the string and will output the original string as a single-element array.

FAQ

Q: Can I split a string by multiple delimiters?

A: No, the Split Text Node can only split a string by a single delimiter. If you want to split a string by multiple delimiters, you can use multiple Split Text Nodes in sequence.

Q: Can I split a string by a regular expression?

A: No, the Split Text Node does not support splitting a string by a regular expression. You can use a Code Node to split a string by a regular expression using JavaScript's split() method.

Q: What happens if the delimiter is not found in the string?

A: If the delimiter is not found in the string, the Split Text Node will output the original string as a single-element array.

See Also