1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-15 17:02:06 +01:00

Dip the regex set into caramell - hmmm

This commit is contained in:
Paul Schaub 2023-07-05 18:08:54 +02:00
parent 38d9351620
commit 570bb1a512
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -43,16 +43,9 @@ data class RegexSet(val regexStrings: Set<String>) {
* That is if at least one RegEx in the set matches the [string], or if the set represents a wildcard.
*/
fun matches(string: String): Boolean {
if (regexStrings.isEmpty()) {
return true
}
for (regex in regexStrings) {
val matcher = Pattern.compile(regex).matcher(string)
if (matcher.find()) {
return true
// wildcard or any match
return regexStrings.isEmpty() || regexStrings.any {
Pattern.compile(it).matcher(string).find()
}
}
return false
}
}