Skip to main content

Cut

Splits a string at the first occurrence of a separator into "before" and "after" parts.

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 cut/split.
  • Separator - The separator to cut at (first occurrence only).

Options

This node does not have configurable options.

Output

  • Result - An object containing:
    • before - The part of the string before the separator
    • after - The part of the string after the separator

If separator is not found, before contains the entire string and after is empty.

How It Works

The Cut node finds the first occurrence of the separator and splits the string into two parts:

  1. Everything before the separator → result.before
  2. Everything after the separator → result.after
  3. The separator itself is not included in either part
  4. If separator not found: entire string goes to before, after is empty

Usage Examples

Example 1: Split Email Address

  • String: "user@example.com"
  • Separator: "@"
  • Result:
    • before: "user"
    • after: "example.com"

Example 2: Extract Domain

  • String: "https://example.com/path"
  • Separator: "//"
  • Result:
    • before: "https:"
    • after: "example.com/path"

Example 3: Parse Key-Value Pair

  • String: "name=John"
  • Separator: "="
  • Result:
    • before: "name"
    • after: "John"

Example 4: Separator Not Found

  • String: "Hello World"
  • Separator: "@"
  • Result:
    • before: "Hello World"
    • after: "" (empty)

Example 5: Multiple Separators (Uses First)

  • String: "one,two,three"
  • Separator: ","
  • Result:
    • before: "one"
    • after: "two,three"

Tips

  • Only splits at the first occurrence of separator
  • The separator itself is removed from the result
  • Perfect for simple key-value parsing
  • Use Split node if you need to split at all occurrences
  • Access results using ${msg.result.before} and ${msg.result.after}
  • If separator not found, check if after is empty

Common Errors and Solutions

Error: Can't access before/after values

  • Cause: Incorrect variable reference
  • Solution: Use ${msg.result.before} and ${msg.result.after}

Error: Need to split at all occurrences, not just first

  • Solution: Use Split node instead, which returns an array of all parts

Practical RPA Examples

Example: Parse Email

String: "john.doe@company.com"
Separator: "@"
Result:
before: "john.doe" (username)
after: "company.com" (domain)

Example: Extract File Extension

String: "document.pdf"
Separator: "."
Result:
before: "document" (filename)
after: "pdf" (extension)
note

For files with multiple dots (e.g., "file.tar.gz"), this returns first split only. Consider using LastIndex for accurate extension extraction.

Example: Parse URL Protocol

String: "https://api.example.com"
Separator: "://"
Result:
before: "https" (protocol)
after: "api.example.com" (host and path)

Example: Split First Name and Last Name

String: "John Doe Smith"
Separator: " "
Result:
before: "John" (first word)
after: "Doe Smith" (rest)

Example: Parse Log Entry

String: "[ERROR] Connection timeout occurred"
Separator: "] "
Result:
before: "[ERROR" (level)
after: "Connection timeout occurred" (message)

Example: Extract Subdomain

String: "api.staging.example.com"
Separator: "."
Result:
before: "api" (first part)
after: "staging.example.com" (rest)

Working with the Result Object

Access Before Part

Variable: ${msg.result.before}
Use in next node

Access After Part

Variable: ${msg.result.after}
Use in next node

Check if Separator Was Found

If ${msg.result.after} is empty:
Separator was not found
Else:
Separator was found and string was split

Comparison with Other Nodes

NodeUse Case
CutSplit at first occurrence into 2 parts
SplitSplit at all occurrences into array
IndexFind position without splitting
ReplaceReplace separator, don't split

Pattern: Cascading Cuts

Parse complex strings with multiple separators:

Step 1: Cut by "://" → protocol and rest
Step 2: Cut rest by "/" → domain and path
Step 3: Cut domain by ":" → host and port

Example:

"https://example.com:8080/api/users"
Cut 1: "https" | "example.com:8080/api/users"
Cut 2: "example.com:8080" | "api/users"
Cut 3: "example.com" | "8080"
  • Split - Split at all occurrences into array
    • Find position of separator
  • Replace - Replace separator
  • Join - Opposite operation - join parts