Cleanup removeArticals extension function
This commit is contained in:
parent
0b7f8da84e
commit
a088e1ffc2
@ -4,8 +4,10 @@ fun List<String>.trimAll() = map { it.trim() }
|
||||
fun List<String>.dropBlank() = filter { it.isNotBlank() }
|
||||
fun List<String>.dropEmpty() = filter { it.isNotEmpty() }
|
||||
|
||||
private val articleRegex by lazy { "^(an|a|the) ".toRegex(RegexOption.IGNORE_CASE) }
|
||||
|
||||
fun String.removeArticles(): String {
|
||||
return this.replace(Regex("^(an|a|the) ", RegexOption.IGNORE_CASE), "")
|
||||
return this.replace(articleRegex, "")
|
||||
}
|
||||
|
||||
fun String.trimOrNull(): String? {
|
||||
|
Loading…
x
Reference in New Issue
Block a user