Files
Курнат Андрей 2315f25754 Initial QSfera import
2026-06-07 10:20:04 +03:00

32 lines
630 B
Go

package matching
import (
"github.com/trustelem/zxcvbn/match"
"regexp"
)
type regexpMatch struct {
regexes []struct {
Name string
Regexp *regexp.Regexp
}
}
func (r regexpMatch) Matches(password string) []*match.Match {
var matches []*match.Match
for _, rx := range r.regexes {
for _, indexes := range rx.Regexp.FindAllStringIndex(password, -1) {
token := password[indexes[0]:indexes[1]]
matches = append(matches, &match.Match{
Pattern: "regex",
Token: token,
I: indexes[0],
J: indexes[1] - 1,
RegexName: rx.Name,
})
}
}
match.Sort(matches)
return matches
}