From d2c7656e482f7b6313b497fd272c16b1622fd86a Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 23 Jul 2019 15:05:48 +0800 Subject: [PATCH] up --- .../app/model/analyzeRule/AnalyzeByRegex.kt | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByRegex.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByRegex.kt index 3b5226173..c46bbb550 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByRegex.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeByRegex.kt @@ -2,12 +2,10 @@ package io.legado.app.model.analyzeRule import java.util.* import java.util.regex.Pattern -import kotlin.collections.HashMap -import kotlin.collections.set object AnalyzeByRegex { - fun getElement(res: String, regs: Array, index: Int = 0): Map? { + fun getElement(res: String, regs: Array, index: Int = 0): List? { var vIndex = index val resM = Pattern.compile(regs[vIndex]).matcher(res) if (!resM.find()) { @@ -16,9 +14,9 @@ object AnalyzeByRegex { // 判断索引的规则是最后一个规则 return if (vIndex + 1 == regs.size) { // 新建容器 - val info = HashMap() - for (groupIndex in 1 until resM.groupCount()) { - info["$$groupIndex"] = resM.group(groupIndex) + val info = arrayListOf() + for (groupIndex in 0 until resM.groupCount()) { + info.add(resM.group(groupIndex)) } info } else { @@ -30,7 +28,7 @@ object AnalyzeByRegex { } } - fun getElements(res: String, regs: Array, index: Int = 0): List> { + fun getElements(res: String, regs: Array, index: Int = 0): List> { var vIndex = index val resM = Pattern.compile(regs[vIndex]).matcher(res) if (!resM.find()) { @@ -39,13 +37,13 @@ object AnalyzeByRegex { // 判断索引的规则是最后一个规则 if (vIndex + 1 == regs.size) { // 创建书息缓存数组 - val books = ArrayList>() + val books = ArrayList>() // 提取列表 do { // 新建容器 - val info = HashMap() - for (groupIndex in 1 until resM.groupCount()) { - info["$$groupIndex"] = resM.group(groupIndex) + val info = arrayListOf() + for (groupIndex in 0 until resM.groupCount()) { + info.add(resM.group(groupIndex)) } books.add(info) } while (resM.find())