public class MatchResultSubstitution extends Substitution
MatchResult来替换字符串中的变量。通常变量以'$'开始,例如:
$1,$2等,但MatchResultSubstitution类支持对多个
MatchResult变量进行替换,分别对应不同的前缀。| Modifier and Type | Field and Description |
|---|---|
static MatchResult |
EMPTY_MATCH_RESULT
代表一个成功但无内容的匹配结果。
|
replacementPrefixes| Constructor and Description |
|---|
MatchResultSubstitution()
创建一个替换。替换所有
$num所代表的变量。 |
MatchResultSubstitution(MatchResult result)
创建一个替换。替换所有
$num所代表的变量。 |
MatchResultSubstitution(String replacementPrefixes,
MatchResult... results)
创建一个替换。将所有指定前缀所代表的变量替换成相应
MatchResult.group(num)的值。 |
| Modifier and Type | Method and Description |
|---|---|
MatchResult |
getMatch()
取得匹配。
|
MatchResult |
getMatch(int index)
取得匹配。
|
protected String |
group(int index,
int groupNumber)
子类覆盖此方法,以提供指定类型、指定group序号的的replacement结果。
|
void |
setMatchResult(MatchResult result)
设置新匹配。
|
void |
setMatchResults(MatchResult... results)
设置新匹配。
|
String |
toString() |
substitute, substitutepublic static final MatchResult EMPTY_MATCH_RESULT
public MatchResultSubstitution()
$num所代表的变量。public MatchResultSubstitution(MatchResult result)
$num所代表的变量。public MatchResultSubstitution(String replacementPrefixes, MatchResult... results)
MatchResult.group(num)的值。public void setMatchResult(MatchResult result)
public void setMatchResults(MatchResult... results)
public MatchResult getMatch()
public MatchResult getMatch(int index)
protected String group(int index, int groupNumber)
Substitutiongroup in class SubstitutionCopyright © 2006–2018 TinyGroup. All rights reserved.