public class PatternReplacer
extends java.lang.Object
implements java.io.Serializable
Defines a source pattern (regular expresssion) and its replacement string, along with a method for performing the replacement.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
replacementPattern
Replacement.
|
protected java.lang.String |
sourcePattern
Source pattern string.
|
protected java.util.regex.Matcher |
sourcePatternMatcher
Compiled source pattern matcher.
|
Constructor and Description |
---|
PatternReplacer(java.lang.String sourcePattern,
java.lang.String replacementPattern)
Create a pattern replacer definition.
|
Modifier and Type | Method and Description |
---|---|
java.util.regex.Matcher |
getMatcher()
Get pattern matcher.
|
java.lang.String[] |
matchGroups(java.lang.String s)
Return matched groups.
|
java.lang.String |
replace(java.lang.String s)
Perform replacement.
|
java.lang.String |
toString()
Display pattern replacer as string.
|
protected java.lang.String sourcePattern
protected java.util.regex.Matcher sourcePatternMatcher
protected java.lang.String replacementPattern
public PatternReplacer(java.lang.String sourcePattern, java.lang.String replacementPattern)
sourcePattern
- Source pattern string as a
regular expression.replacementPattern
- Replacement pattern string
as a regular expression
replacement expression.public java.lang.String[] matchGroups(java.lang.String s)
s
- String to match.public java.lang.String replace(java.lang.String s)
s
- String in which to perform replacement.public java.util.regex.Matcher getMatcher()
public java.lang.String toString()
toString
in class java.lang.Object