修复规则解析bug

pull/395/head
gedoor 4 years ago
parent 98de63b04c
commit c06c26a36f
  1. 8
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt

@ -480,12 +480,18 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
} }
} }
/**
* 拆分\$\d{1,2}
*/
private fun splitRegex(ruleStr: String) { private fun splitRegex(ruleStr: String) {
var start = 0 var start = 0
var tmp: String var tmp: String
val ruleStrArray = ruleStr.split("##") val ruleStrArray = ruleStr.split("##")
val regexMatcher = regexPattern.matcher(ruleStrArray[0]) val regexMatcher = regexPattern.matcher(ruleStrArray[0])
while (regexMatcher.find()) { while (regexMatcher.find()) {
if (mode != Mode.Js) {
mode = Mode.Regex
}
if (regexMatcher.start() > start) { if (regexMatcher.start() > start) {
tmp = ruleStr.substring(start, regexMatcher.start()) tmp = ruleStr.substring(start, regexMatcher.start())
ruleType.add(0) ruleType.add(0)
@ -652,7 +658,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
private val getPattern = Pattern.compile("@get:\\{([^}]+?)\\}", Pattern.CASE_INSENSITIVE) private val getPattern = Pattern.compile("@get:\\{([^}]+?)\\}", Pattern.CASE_INSENSITIVE)
private val evalPattern = private val evalPattern =
Pattern.compile("@get:\\{[^}]+?\\}|\\{\\{[\\w\\W]*?\\}\\}", Pattern.CASE_INSENSITIVE) Pattern.compile("@get:\\{[^}]+?\\}|\\{\\{[\\w\\W]*?\\}\\}", Pattern.CASE_INSENSITIVE)
private val regexPattern = Pattern.compile("\\\$\\d{1,2}") private val regexPattern = Pattern.compile("\\$\\d{1,2}")
} }
} }

Loading…
Cancel
Save