Trim First
Synopsis
A text processing processor that removes a specified number of characters or predefined keywords from the beginning of strings, providing precise control over prefix removal for data cleaning and normalization tasks.
Schema
- trim_first:
field: <ident>
count: <numeric>
keywords: <string[]>
target_field: <ident>
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(s) to process |
count | N | - | Number of characters to remove from beginning |
keywords | N | - | Keywords to remove from beginning |
target_field | N | field | Field to store the trimmed result |
description | N | - | Explanatory note |
if | N | - | Condition to run |
ignore_failure | N | false | Continue if trimming 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 two trimming modes: character count-based trimming and keyword-based trimming. Both modes can be used together, with character trimming applied first followed by keyword trimming.
The processor supports both single strings and string arrays, applying the trimming operation to each string element.
Character count trimming removes the specified number of characters from the start of each string. If the count exceeds the string length, the entire string is removed, resulting in an empty string.
Keyword trimming removes matching prefixes from the beginning of strings. Multiple keywords can be specified, and each is checked sequentially for prefix matches.
Ensure the count parameter contains valid numeric values to avoid processing errors.
Examples
Character Count Trimming
Removing first characters from strings... |
|
removes the prefixes: |
|
Keyword Trimming
Removing specific keywords from beginning... |
|
removes the log level prefixes: |
|
Array Processing
Processing string arrays... |
|
extracts just the filenames: |
|
Multiple Keywords
Removing various prefixes... |
|
removes all log level prefixes: |
|
Combined Trimming
Using both character count and keywords... |
|
applies both trimming methods: |
|
Conditional Trimming
Trimming based on conditions... |
|
applies trimming when condition matches: |
|