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.