mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-25 12:27:58 +01:00
Dip the regex set into caramell - hmmm
This commit is contained in:
parent
38d9351620
commit
570bb1a512
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.
|
* 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 {
|
fun matches(string: String): Boolean {
|
||||||
if (regexStrings.isEmpty()) {
|
// wildcard or any match
|
||||||
return true
|
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