|
|
@ -340,15 +340,17 @@ class AnalyzeRule(val ruleData: RuleDataInterface) : JsExtensions { |
|
|
|
var vResult = result |
|
|
|
var vResult = result |
|
|
|
if (rule.replaceRegex.isNotEmpty()) { |
|
|
|
if (rule.replaceRegex.isNotEmpty()) { |
|
|
|
vResult = if (rule.replaceFirst) { |
|
|
|
vResult = if (rule.replaceFirst) { |
|
|
|
val pattern = Pattern.compile(rule.replaceRegex) |
|
|
|
kotlin.runCatching { |
|
|
|
val matcher = pattern.matcher(vResult) |
|
|
|
vResult.replaceFirst(rule.replaceRegex.toRegex(), rule.replacement) |
|
|
|
if (matcher.find()) { |
|
|
|
}.getOrElse { |
|
|
|
matcher.group(0)!!.replaceFirst(rule.replaceRegex.toRegex(), rule.replacement) |
|
|
|
vResult.replaceFirst(rule.replaceRegex, rule.replacement) |
|
|
|
} else { |
|
|
|
|
|
|
|
"" |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
kotlin.runCatching { |
|
|
|
vResult.replace(rule.replaceRegex.toRegex(), rule.replacement) |
|
|
|
vResult.replace(rule.replaceRegex.toRegex(), rule.replacement) |
|
|
|
|
|
|
|
}.getOrElse { |
|
|
|
|
|
|
|
vResult.replace(rule.replaceRegex, rule.replacement) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return vResult |
|
|
|
return vResult |
|
|
|