Trim Last
Synopsis
A text processing processor that removes a specified number of characters or predefined keywords from the end of strings, providing precise control over suffix removal for data cleaning and normalization tasks.
Schema
- trim_last:
field: <ident>
count: <integer>
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 end |
keywords | N | - | Keywords to remove from end |
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 after keyword trimming to ensure precise suffix removal.
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 end of each string. If the count exceeds the string length, the entire string is removed, resulting in an empty string.
Keyword trimming removes matching suffixes from the end of strings. Multiple keywords can be specified, and each is checked sequentially for suffix matches.
Ensure the count parameter contains valid numeric values to avoid processing errors.
Examples
Character Count Trimming
Removing last characters from strings... |
|
removes the suffixes: |
|
Keyword Trimming
Removing specific keywords from end... |
|
removes the file extensions: |
|
Array Processing
Processing string arrays... |
|
removes trailing slashes: |
|
File Extension Removal
Removing various file extensions... |
|
removes all file extensions: |
|
Combined Trimming
Using both keywords and character count... |
|
applies both trimming methods: |
|
Conditional Trimming
Trimming based on conditions... |
|
applies trimming when condition matches: |
|