pull/438/head
gedoor 4 years ago
parent 00e210e8de
commit 3cb703d88b
  1. 15
      app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeRule.kt

@ -649,16 +649,12 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
* 章节数转数字
*/
fun toNumChapter(s: String?): String? {
if (s == null) {
return null
}
val pattern = Pattern.compile("(第)(.+?)(章)")
val matcher = pattern.matcher(s)
return if (matcher.find()) {
matcher.group(1)!! + StringUtils.stringToInt(matcher.group(2)) + matcher.group(3)
} else {
s
s ?: return null
val matcher = titleNumPattern.matcher(s)
if (matcher.find()) {
return "${matcher.group(1)}${StringUtils.stringToInt(matcher.group(2))}${matcher.group(3)}"
}
return s
}
companion object {
@ -667,6 +663,7 @@ class AnalyzeRule(var book: BaseBook? = null) : JsExtensions {
private val evalPattern =
Pattern.compile("@get:\\{[^}]+?\\}|\\{\\{[\\w\\W]*?\\}\\}", Pattern.CASE_INSENSITIVE)
private val regexPattern = Pattern.compile("\\$\\d{1,2}")
private val titleNumPattern = Pattern.compile("(第)(.+?)(章)")
}
}

Loading…
Cancel
Save