StripBetweenTransformer
Removes any content found between a matching start and end strings.
Notes
The matching strings are defined in pairs and multiple ones can be specified at once.
This class can be used as a pre-parsing (text content-types only) or post-parsing handlers.
Examples
The following will strip all text between (and including) these two HTML comments: <!-- SIDENAV_START --> and <!-- SIDENAV_END -->.
- YAML
- JSON
- XML
handler:
class: StripBetweenTransformer
operations:
- inclusive: true
startMatcher:
method: REGEX
pattern: <![CDATA[<!-- SIDENAV_START -->]]>
endMatcher:
method: REGEX
pattern: <![CDATA[<!-- SIDENAV_END -->]]>
{
"handler": {
"class": "StripBetweenTransformer",
"operations": [
{
"inclusive": true,
"startMatcher": {
"method": "REGEX",
"pattern": "<![CDATA[<!-- SIDENAV_START -->]]>"
},
"endMatcher": {
"method": "REGEX",
"pattern": "<![CDATA[<!-- SIDENAV_END -->]]>"
}
}
]
}
}
<handler>
<class>StripBetweenTransformer</class>
<operations>
<op>
<inclusive>true</inclusive>
<startMatcher>
<method>REGEX</method>
<pattern><![CDATA[<!-- SIDENAV_START -->]]></pattern>
</startMatcher>
<endMatcher>
<method>REGEX</method>
<pattern><![CDATA[<!-- SIDENAV_END -->]]></pattern>
</endMatcher>
</op>
</operations>
</handler>
Usage
Full configuration skeleton, with every option and its default
- YAML
- JSON
- XML
class: StripBetweenTransformer
fieldMatcher:
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
label: string
maxReadSize: 0
operations:
- endMatcher: {}
inclusive: false
startMatcher: {}
sourceCharset: string
{
"class": "StripBetweenTransformer",
"fieldMatcher": {
"ignoreCase": false,
"ignoreDiacritic": false,
"matchEmpty": false,
"method": "BASIC",
"negateMatches": false,
"partial": false,
"pattern": "string",
"replaceAll": false,
"trim": false
},
"label": "string",
"maxReadSize": 0,
"operations": [
{
"endMatcher": {},
"inclusive": false,
"startMatcher": {}
}
],
"sourceCharset": "string"
}
<handler>
<class>StripBetweenTransformer</class>
<fieldMatcher>
<ignoreCase>false</ignoreCase>
<ignoreDiacritic>false</ignoreDiacritic>
<matchEmpty>false</matchEmpty>
<method>BASIC</method>
<negateMatches>false</negateMatches>
<partial>false</partial>
<pattern>string</pattern>
<replaceAll>false</replaceAll>
<trim>false</trim>
</fieldMatcher>
<label>string</label>
<maxReadSize>0</maxReadSize>
<operations>
<op>
<endMatcher/>
<inclusive>false</inclusive>
<startMatcher/>
</op>
</operations>
<sourceCharset>string</sourceCharset>
</handler>
Properties
| Property | Type | Required | Default |
|---|---|---|---|
fieldMatcher | TextMatcher | No | TextMatcher |
label | string | No | - |
maxReadSize | integer | No | 10000000 |
operations | StripBetweenOperation[] | No | - |
sourceCharset | string | No | - |
Property Details
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.
maxReadSize
Max characters to read at once
operations
Allows defining multiple operations as a list.
sourceCharset
Sets the character encoding of the source document to ensure proper reading and processing.