1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-09-27 18:19:34 +02:00

Dip the regex set into caramell - hmmm

This commit is contained in:
Paul Schaub 2023-07-05 18:08:54 +02:00
parent a202a34941
commit 9a8ec26737
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
// wildcard or any match
return regexStrings.isEmpty() || regexStrings.any {
Pattern.compile(it).matcher(string).find()
}
for (regex in regexStrings) {
val matcher = Pattern.compile(regex).matcher(string)
if (matcher.find()) {
return true
}
}
return false
}
}