From 8ab80800cb33fa17307581cb055827795528734d Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 23 Oct 2019 09:29:32 +0800 Subject: [PATCH] up --- .../app/model/analyzeRule/AnalyzeRule.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt index 6a822e199..2e1b854fc 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt @@ -438,7 +438,7 @@ class AnalyzeRule(private var book: BaseBook? = null) { } //分离put rule = splitPutRule(rule, putMap) - //get,{{ }},$, 替换 + //@get,{{ }},$1, 拆分 var start = 0 var tmp: String val evalMatcher = evalPattern.matcher(rule) @@ -476,6 +476,9 @@ class AnalyzeRule(private var book: BaseBook? = null) { } } + /** + * 替换@get,{{ }},$1, + */ fun makeUpRule(result: Any?) { val infoVal = StringBuilder() if (ruleParam.isNotEmpty()) { @@ -543,15 +546,6 @@ class AnalyzeRule(private var book: BaseBook? = null) { return SCRIPT_ENGINE.eval(jsStr, bindings) } - companion object { - private val putPattern = Pattern.compile("@put:(\\{[^}]+?\\})", Pattern.CASE_INSENSITIVE) - private val getPattern = Pattern.compile("@get:\\{([^}]+?)\\}", Pattern.CASE_INSENSITIVE) - private val evalPattern = Pattern.compile( - "@get:\\{[^}]+?\\}|\\{\\{[\\w\\W]*?\\}\\}|\\$\\d{1,2}", - Pattern.CASE_INSENSITIVE - ) - } - /** * js实现跨域访问,不能删 */ @@ -588,4 +582,14 @@ class AnalyzeRule(private var book: BaseBook? = null) { s } } + + companion object { + private val putPattern = Pattern.compile("@put:(\\{[^}]+?\\})", Pattern.CASE_INSENSITIVE) + private val getPattern = Pattern.compile("@get:\\{([^}]+?)\\}", Pattern.CASE_INSENSITIVE) + private val evalPattern = Pattern.compile( + "@get:\\{[^}]+?\\}|\\{\\{[\\w\\W]*?\\}\\}|\\$\\d{1,2}", + Pattern.CASE_INSENSITIVE + ) + } + }