Skip to main content

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".

pattern: Paul

wildcard

The following will successfully match this sentence: "It seems Paul and Marc are friends".

method: WILDCARD
ignoreCase: true
partial: true
pattern: paul*mar?

Usage

Full configuration skeleton, with every option and its default
ignoreCase: false
ignoreDiacritic: false
matchEmpty: false
method: BASIC
negateMatches: false
partial: false
pattern: string
replaceAll: false
trim: false

Properties

PropertyTypeRequiredDefault
ignoreCasebooleanNofalse
ignoreDiacriticbooleanNofalse
matchEmptybooleanNofalse
methodenumNoBASIC
negateMatchesbooleanNofalse
partialbooleanNofalse
patternstringNo-
replaceAllbooleanNofalse
trimbooleanNofalse

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

  • BASIC
  • CSV
  • WILDCARD
  • REGEX

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.