This commit is contained in:
Benoit Marty 2022-01-25 15:54:15 +01:00
parent 63b3def667
commit d9386cd61f

View File

@ -56,12 +56,13 @@ class EventMatchCondition(
if (wordsOnly) { if (wordsOnly) {
value.caseInsensitiveFind(pattern) value.caseInsensitiveFind(pattern)
} else { } else {
val modPattern = if (pattern.hasSpecialGlobChar()) val modPattern = if (pattern.hasSpecialGlobChar()) {
// Regex.containsMatchIn() is way faster without leading and trailing // Regex.containsMatchIn() is way faster without leading and trailing
// stars, that don't make any difference for the evaluation result // stars, that don't make any difference for the evaluation result
pattern.removePrefix("*").removeSuffix("*").simpleGlobToRegExp() pattern.removePrefix("*").removeSuffix("*").simpleGlobToRegExp()
else } else {
pattern.simpleGlobToRegExp() pattern.simpleGlobToRegExp()
}
val regex = Regex(modPattern, RegexOption.DOT_MATCHES_ALL) val regex = Regex(modPattern, RegexOption.DOT_MATCHES_ALL)
regex.containsMatchIn(value) regex.containsMatchIn(value)
} }