替换规则支持js,可以用js判断匹配到的内容决定替换为什么,匹配到的内容变量为result,替换为@js:开头则自动采用js判断替换内容
This commit is contained in:
@@ -29,7 +29,7 @@ suspend fun CharSequence.replace(regex: Regex, replacement: String, timeout: Lon
|
||||
val stringBuffer = StringBuffer()
|
||||
while (matcher.find()) {
|
||||
val bindings = SimpleBindings()
|
||||
bindings["result"] = matcher.group(1)
|
||||
bindings["result"] = matcher.group()
|
||||
val jsResult = AppConst.SCRIPT_ENGINE.eval(js, bindings).toString()
|
||||
matcher.appendReplacement(stringBuffer, jsResult)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user