Skip to main content

$split

The $split operator splits a string into an array of substrings based on a separator.

Input

  • An array containing exactly two string values: the input string and the separator

Output

  • An array of substrings created by splitting the input string at each occurrence of the separator

Examples

Basic Split

{
  "$split": [
    "apple,banana,orange",
    ","
  ]
}
Result: ["apple", "banana", "orange"]

Split by Space

{
  "$split": [
    "Hello World Test",
    " "
  ]
}
Result: ["Hello", "World", "Test"]

Field Value

{
  "$split": [
    {
      "$input": "tags"
    },
    ","
  ]
}
Result: An array of tags split by commas from the tags field