mirror of
https://github.com/gedoor/legado.git
synced 2024-09-03 09:55:00 +08:00
parent
02fcba0218
commit
7d62e0d5c6
@ -388,6 +388,7 @@ class AnalyzeRule(
|
||||
if (rule.replaceRegex.isEmpty()) return result
|
||||
var vResult = result
|
||||
vResult = if (rule.replaceFirst) {
|
||||
/* ##match##replace### 获取第一个匹配到的结果并进行替换 */
|
||||
kotlin.runCatching {
|
||||
val pattern = Pattern.compile(rule.replaceRegex)
|
||||
val matcher = pattern.matcher(vResult)
|
||||
@ -397,9 +398,10 @@ class AnalyzeRule(
|
||||
""
|
||||
}
|
||||
}.getOrElse {
|
||||
vResult.replaceFirst(rule.replaceRegex, rule.replacement)
|
||||
rule.replacement
|
||||
}
|
||||
} else {
|
||||
/* ##match##replace 替换*/
|
||||
kotlin.runCatching {
|
||||
vResult.replace(rule.replaceRegex.toRegex(), rule.replacement)
|
||||
}.getOrElse {
|
||||
|
Loading…
Reference in New Issue
Block a user