mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 09:25:49 +03:00
Refactor: Kotlin style
This commit is contained in:
parent
f5ea4fb6ac
commit
aca8fd7f3d
1 changed files with 12 additions and 10 deletions
|
@ -23,16 +23,18 @@ internal fun String.hasSpecialGlobChar(): Boolean {
|
|||
|
||||
// Very simple glob to regexp converter
|
||||
internal fun String.simpleGlobToRegExp(): String {
|
||||
var out = "" // "^"
|
||||
for (element in this) {
|
||||
when (element) {
|
||||
'*' -> out += ".*"
|
||||
'?' -> out += '.'.toString()
|
||||
'.' -> out += "\\."
|
||||
'\\' -> out += "\\\\"
|
||||
else -> out += element
|
||||
val string = this
|
||||
return buildString {
|
||||
// append("^")
|
||||
string.forEach { char ->
|
||||
when (char) {
|
||||
'*' -> append(".*")
|
||||
'?' -> append(".")
|
||||
'.' -> append("\\.")
|
||||
'\\' -> append("\\\\")
|
||||
else -> append(char)
|
||||
}
|
||||
}
|
||||
// append("$")
|
||||
}
|
||||
out += "" // '$'.toString()
|
||||
return out
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue