public class HighMultiReplacer extends StrReplacer
注意: 如果需要被替换的关键字出现交叉,最先匹配中的关键字会被替换 1、"abc","ab" 会优先替换"ab" 2、"abed","be" 会优先替换"abed" 3、"abc", "bc" 会优先替换"abc"
Constructor and Description |
---|
HighMultiReplacer(Map<String,String> map)
构造
|
Modifier and Type | Method and Description |
---|---|
CharSequence |
apply(CharSequence str)
执行替换,按照
StrReplacer.replace(CharSequence, int, StringBuilder) 逻辑替换对应部分,其它部分保持原样 |
static HighMultiReplacer |
of(Map<String,String> map)
生成一个HighMultiReplacer对象
|
protected int |
replace(CharSequence str,
int pos,
StringBuilder out)
抽象的字符串替换方法,通过传入原字符串和当前位置,执行替换逻辑,返回处理或替换的字符串长度部分。
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
identity
public static HighMultiReplacer of(Map<String,String> map)
map
- key为需要被查找的字符串,value为对应的替换的值protected int replace(CharSequence str, int pos, StringBuilder out)
StrReplacer
replace
in class StrReplacer
str
- 被处理的字符串pos
- 当前位置out
- 输出public CharSequence apply(CharSequence str)
StrReplacer
StrReplacer.replace(CharSequence, int, StringBuilder)
逻辑替换对应部分,其它部分保持原样apply
in interface Function<CharSequence,CharSequence>
apply
in class StrReplacer
str
- 被处理的字符串Copyright © 2025. All rights reserved.