Take
Synopsis
A data extraction processor that takes a specified number of characters from strings or elements from arrays, supporting extraction from the beginning or end of the data with optional reversal of the extracted content.
Schema
- take:
field: <ident>
length: <string>
target_field: <ident>
reverse: <boolean>
mirror: <boolean>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>
Configuration
The following fields are used to define the processor:
Field | Required | Default | Description |
---|---|---|---|
field | Y | - | Field containing the string or array to process |
length | N | all | Number of characters or elements to take |
target_field | N | field | Field to store the extracted content |
reverse | N | false | Take from end instead of beginning |
mirror | N | false | Reverse the order of taken elements |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue if extraction fails |
ignore_missing | N | false | Continue if source field doesn't exist |
on_failure | N | - | See Handling Failures |
on_success | N | - | See Handling Success |
tag | N | - | Identifier |
Details
The processor supports extraction from multiple data types including strings, string arrays, and generic interface arrays. When no length is specified, the entire content is returned.
The length parameter accepts string values for template compatibility and dynamic length calculation.
String processing extracts the specified number of characters, while array processing extracts elements. The reverse option allows extraction from the end of the data, useful for getting file extensions or recent log entries.
The mirror option reverses the order of extracted content after taking, providing additional flexibility for data manipulation scenarios.
Ensure the length parameter contains valid numeric values to avoid processing errors.
Examples
String Character Extraction
Taking first characters from a string... |
|
extracts the beginning: |
|
File Extension Extraction
Taking last characters for extension... |
|
extracts the file extension: |
|
Array Element Extraction
Taking elements from an array... |
|
extracts first three elements: |
|
Recent Log Entries
Getting recent entries from end of array... |
|
extracts the most recent entries: |
|
Mirrored Text Extraction
Taking and reversing characters... |
|
extracts and reverses the prefix: |
|
In-Place Processing
Truncating field in place... |
|
truncates the original field: |
|