Skip to main content

SubstringTransformer

Keep a substring of the content matching a begin and end character indexes.

Notes

Useful when you have to truncate long content, or when you know precisely where is located the text to extract in some files.

The begin value is inclusive, while the end value is exclusive. Both are optional. When not specified (or a negative value), the index is assumed to be the beginning and end of the content, respectively.

This class can be used as a pre-parsing (text content-types only) or post-parsing handlers.

Examples

The following example truncates long text to be 10,000 characters maximum.

handler:
class: SubstringTransformer
end: 10000

Usage

Full configuration skeleton, with every option and its default
class: SubstringTransformer
begin: 0
end: 0
fieldMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
label: string
sourceCharset: string

Properties

PropertyTypeRequiredDefault
beginintegerNo0
endintegerNo-1
fieldMatcherTextMatcherNoTextMatcher
labelstringNo-
sourceCharsetstringNo-

Property Details

begin

The index of the beginning of the substring.

end

The index of the end of the substring.

fieldMatcher

Matches document fields based on specified patterns and methods

label

An optional, user-supplied label for this step in the importer pipeline. It has no effect on processing — it exists purely to help identify this step, for example in large configurations or in the visual configurator.

sourceCharset

Sets the character encoding of the source document to ensure proper reading and processing.