Module: Zxcvbn::Matchers::RegexHelpers Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Shared helper for iterating non-overlapping regex matches over a password.
Instance Method Summary collapse
-
#re_match_all(regex, password) {|match, re_match| ... } ⇒ void
private
Yields a Zxcvbn::Match and the underlying MatchData for every non-overlapping occurrence of regex in password.
Instance Method Details
#re_match_all(regex, password) {|match, re_match| ... } ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Yields a Zxcvbn::Match and the underlying MatchData for every non-overlapping occurrence of regex in password.
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/zxcvbn/matchers/regex_helpers.rb', line 20 def re_match_all(regex, password) pos = 0 while (re_match = regex.match(password, pos)) i, j = re_match.offset(0) pos = j j -= 1 match = MatchBuilder.new(i:, j:, token: password.slice(i, j - i + 1)) yield match, re_match end end |