TextMatcher
A configurable class offering a few different ways to perform text matching and replacing. Note the replaceAll property is only applicable where replacement is supported.
Notes
A configurable class offering a few different ways to perform text matching and replacing. Note the replaceAll property is only applicable where replacement is supported.
Examples
basic
The most basic form, performing an exact match on entire text. It will match "Paul", but not "paul", and not "I am Paul".
- YAML
- JSON
- XML
pattern: Paul
{
"pattern": "Paul"
}
<pattern>Paul</pattern>
wildcard
The following will successfully match this sentence: "It seems Paul and Marc are friends".
- YAML
- JSON
- XML
method: WILDCARD
ignoreCase: true
partial: true
pattern: paul*mar?
{
"method": "WILDCARD",
"ignoreCase": true,
"partial": true,
"pattern": "paul*mar?"
}
<method>WILDCARD</method>
<ignoreCase>true</ignoreCase>
<partial>true</partial>
<pattern>paul*mar?</pattern>
Usage
Full configuration skeleton, with every option and its default
- YAML
- JSON
- XML
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false
{
"ignoreCase": false,
"ignoreDiacritic": false,
"matchEmpty": false,
"method": "BASIC",
"negateMatches": false,
"partial": false,
"pattern": "string",
"replaceAll": false,
"trim": false
}
<textMatcher>
<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>
</textMatcher>
Properties
| Property | Type | Required | Default |
|---|---|---|---|
ignoreCase | boolean | No | false |
ignoreDiacritic | boolean | No | false |
matchEmpty | boolean | No | false |
method | enum | No | BASIC |
negateMatches | boolean | No | false |
partial | boolean | No | false |
pattern | string | No | - |
replaceAll | boolean | No | false |
trim | boolean | No | false |
Property Details
ignoreCase
When enabled, matching is performed without regard to character case.
ignoreDiacritic
When enabled, diacritical marks (e.g., accents) are ignored when performing matching or replacing.
matchEmpty
When enabled, null or empty strings are considered a positive match. To also treat blank (whitespace-only) values as matches, enable trim as well.
method
The matching method to use. Supported values are: BASIC (default, exact text match), CSV (comma-separated list of basic matches), WILDCARD (* matches any series of characters, ? matches any single character), and REGEX (Java-style regular expression matching).
Allowed Values
BASICCSVWILDCARDREGEX
negateMatches
When enabled, the result of a match is inverted — a pattern that would normally match will instead be treated as a non-match, and vice versa.
partial
When enabled, the pattern only needs to match a portion of the text rather than the entire value. By default the full text must match.
pattern
The text or expression used for matching, whose interpretation depends on the selected method.
replaceAll
When enabled, all occurrences of the pattern are replaced. When disabled, only the first occurrence is replaced. Only applicable when replacement is supported.
trim
When enabled, leading and trailing whitespace is removed from the field value before processing.