public class RegExReplacementBuilder
extends java.lang.Object
The logic is based on java.util.regex.Matcher.appendReplacement method, special characters (\n, \r, \t, \f, \b, \xNNNN) and case conversion characters (\l, \u, \L, \U, \E) are additionally supported.
Instances of this class are not safe for use by multiple concurrent threads, just as Matcher
instances are.
Constructor and Description |
---|
RegExReplacementBuilder(java.util.regex.Matcher matcher) |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
createReplacement(java.lang.String template)
Generates a replacement string from provided template value, substituting referenced capturing group values, and processing supported
special and control characters.
|
static void |
validate(java.util.regex.Pattern pattern,
java.lang.String template)
Validates the replacement template.
|
public RegExReplacementBuilder(java.util.regex.Matcher matcher)
public static void validate(java.util.regex.Pattern pattern, java.lang.String template) throws java.lang.IllegalArgumentException
pattern
- current patterntemplate
- replacement templatejava.lang.IllegalArgumentException
- if template is malformedpublic java.lang.String createReplacement(java.lang.String template)
Matcher used to create this instance of RegExReplacementBuilder is supposed to be in a state
created by a successful find()
or find(int)
invocation.