Move Regex out of loop
This commit is contained in:
parent
6a496de181
commit
6353366e63
1 changed files with 5 additions and 3 deletions
|
|
@ -321,12 +321,14 @@ abstract class HttpSource : CatalogueSource {
|
||||||
protected open suspend fun fetchRelatedMangaListBySearch(manga: SManga): List<SManga> {
|
protected open suspend fun fetchRelatedMangaListBySearch(manga: SManga): List<SManga> {
|
||||||
fun String.stripKeyword(): List<String> {
|
fun String.stripKeyword(): List<String> {
|
||||||
val regexWhitespace = Regex("\\s+")
|
val regexWhitespace = Regex("\\s+")
|
||||||
// remove special character
|
val regexSpecialCharacters = Regex("[\\[(!~@#$%^&*|,?:\"<>)\\]]")
|
||||||
return replace(Regex("[\\[(!~@#$%^&*|,?:\"<>)\\]]"), " ")
|
val regexNumberOnly = Regex("^\\d+$")
|
||||||
|
|
||||||
|
return replace(regexSpecialCharacters, " ")
|
||||||
.split(regexWhitespace)
|
.split(regexWhitespace)
|
||||||
.map {
|
.map {
|
||||||
// remove number only
|
// remove number only
|
||||||
it.replace(Regex("^\\d+$"), "")
|
it.replace(regexNumberOnly, "")
|
||||||
.lowercase(Locale.getDefault())
|
.lowercase(Locale.getDefault())
|
||||||
}
|
}
|
||||||
// exclude single character
|
// exclude single character
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue