From f931fd1eff71fbe03d7c0c32795a5956420db56a Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 15 Sep 2021 21:56:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/help/ContentProcessor.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/help/ContentProcessor.kt b/app/src/main/java/io/legado/app/help/ContentProcessor.kt index b8da34314..67889d52f 100644 --- a/app/src/main/java/io/legado/app/help/ContentProcessor.kt +++ b/app/src/main/java/io/legado/app/help/ContentProcessor.kt @@ -15,6 +15,8 @@ class ContentProcessor private constructor( ) { companion object { + private val fbsArr = + arrayOf("\\", "$", "(", ")", "*", "+", ".", "[", "]", "?", "^", "{", "}", "|") private val processors = hashMapOf>() fun get(bookName: String, bookOrigin: String): ContentProcessor { @@ -66,8 +68,14 @@ class ContentProcessor private constructor( it.code <= 0x20 || it == ' ' || it == ',' || it == ',' } //去除重复标题 -// val titleRegex = "^(\\s|\\pP|${book.name})*${chapter.title}(\\s|\\pP)+".toRegex() -// mContent = mContent.replace(titleRegex, "") + var name = book.name + var title = chapter.title + fbsArr.forEach { + name = name.replace(it, "\\" + name) + title = title.replace(it, "\\" + name) + } + val titleRegex = "^(\\s|\\pP|${name})*${title}(\\s|\\pP)+".toRegex() + mContent = mContent.replace(titleRegex, "") if (includeTitle) { //重新添加标题 mContent = chapter.getDisplayTitle() + "\n" + mContent