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:
parent
a202a34941
commit
9a8ec26737
1 changed files with 3 additions and 10 deletions
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue