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 72a4361d5..1bc3a5bcb 100644 --- a/app/src/main/java/io/legado/app/help/ContentProcessor.kt +++ b/app/src/main/java/io/legado/app/help/ContentProcessor.kt @@ -31,18 +31,16 @@ class ContentProcessor(private val bookName: String, private val bookOrigin: Str var content1 = content if (book.getUseReplaceRule()) { replaceRules.forEach { item -> - item.pattern.let { - if (it.isNotEmpty()) { - try { - content1 = if (item.isRegex) { - content1.replace(it.toRegex(), item.replacement) - } else { - content1.replace(it, item.replacement) - } - } catch (e: Exception) { - withContext(Dispatchers.Main) { - App.INSTANCE.toast("${item.name}替换出错") - } + if (item.pattern.isNotEmpty()) { + try { + content1 = if (item.isRegex) { + content1.replace(item.pattern.toRegex(), item.replacement) + } else { + content1.replace(item.pattern, item.replacement) + } + } catch (e: Exception) { + withContext(Dispatchers.Main) { + App.INSTANCE.toast("${item.name}替换出错") } } }