https://kotlinlang.org logo
Title
z

Zan Skamljic

05/28/2021, 8:34 PM
how about
blockList.all { name.contains(it, true) }
?
:thread-please: 1
e

ephemient

05/28/2021, 8:35 PM
&& -> all, || -> any
👍 1
z

Zan Skamljic

05/28/2021, 8:36 PM
oh sorry, misread the line above
but yeah, the solution's the same just swap all for any
c

Colton Idle

05/28/2021, 9:20 PM
THANK YOU!
m

Matteo Mirk

06/01/2021, 10:55 AM
"one|two|three"
    .toRegex(RegexOption.IGNORE_CASE)
    .containsMatchIn(name)
💯 1
m

Michael Böiers

06/01/2021, 12:22 PM
fun String.containsAnyIgnoringCase(vararg s: String) = s.any { contains(it, true) }

"foo bar batz".containsAnyIgnoringCase("bar", "baz")
Better keep the contains api consistent:
fun String.containsAny(vararg s: String, ignoreCase: Boolean = false) = s.any { contains(it, ignoreCase) }

"foo bar batz".containsAny("bar", ignoreCase = true)