split
The split function divides a string into an array of substrings using a specified delimiter. You can optionally retrieve a specific element from the resulting array by index.
Syntax
Section titled “Syntax”{input | split:delimiter:index:fallback}Parameters
Section titled “Parameters”input(string): The string to splitdelimiter(string): The character or string to split byindex(number, optional): Zero-based index of the element to returnfallback(string, optional): Default value if input is empty or index is out of bounds (defaults to “N/A”)
Returns
Section titled “Returns”- If
indexis provided: Returns the element at the specified index or the fallback value - If
indexis not provided: Returns the entire array of split elements
Examples
Section titled “Examples”Basic splitting
Section titled “Basic splitting”{"apple,banana,orange" | split:","}// Returns: ["apple", "banana", "orange"]Get specific element by index
Section titled “Get specific element by index”{"apple,banana,orange" | split:",":1}// Returns: "banana"Using with fallback
Section titled “Using with fallback”{"apple,banana" | split:",":5:"Not found"}// Returns: "Not found"Splitting project names
Section titled “Splitting project names”{project.name | split:"-":2:"N/A"}// Returns: The third segment of a hyphen-separated project name, or "N/A" if not foundSplitting IP addresses
Section titled “Splitting IP addresses”{"192.168.1.1" | split:".":0}// Returns: "192"Splitting file paths
Section titled “Splitting file paths”{file.path | split:"/":3:"Unknown"}// Returns: The fourth segment of the path, or "Unknown" if not found