Simplify loop and when statement.
This commit is contained in:
parent
3f44056243
commit
f609cc7042
|
@ -87,14 +87,13 @@ class EventMatchCondition(
|
||||||
// Very simple glob to regexp converter
|
// Very simple glob to regexp converter
|
||||||
private fun simpleGlobToRegExp(glob: String): String {
|
private fun simpleGlobToRegExp(glob: String): String {
|
||||||
var out = "" // "^"
|
var out = "" // "^"
|
||||||
for (i in 0 until glob.length) {
|
for (element in glob) {
|
||||||
val c = glob[i]
|
when (element) {
|
||||||
when (c) {
|
|
||||||
'*' -> out += ".*"
|
'*' -> out += ".*"
|
||||||
'?' -> out += '.'.toString()
|
'?' -> out += '.'.toString()
|
||||||
'.' -> out += "\\."
|
'.' -> out += "\\."
|
||||||
'\\' -> out += "\\\\"
|
'\\' -> out += "\\\\"
|
||||||
else -> out += c
|
else -> out += element
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out += "" // '$'.toString()
|
out += "" // '$'.toString()
|
||||||
|
|
Loading…
Reference in New Issue