PlayerAndroid/app/src/main/java/software/lavender/music/query/extensions.kt

14 lines
422 B
Kotlin

package software.lavender.music.query
fun String.like(matcher: String): Boolean {
if (matcher.startsWith('%')) {
if (matcher.endsWith('%')) {
return contains(matcher.substring(1, matcher.length - 2))
}
return endsWith(matcher.substring(1))
}
if (matcher.endsWith('%')) {
return startsWith(matcher.substring(0, matcher.length - 2))
}
return this == matcher
}