Module: Zxcvbn::Matchers::RegexHelpers

Included in:
Date, Digits, Year
Defined in:
lib/zxcvbn/matchers/regex_helpers.rb

Instance Method Summary collapse

Instance Method Details

#re_match_all(regex, password) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/zxcvbn/matchers/regex_helpers.rb', line 6

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 = Match.new(
      :i => i,
      :j => j,
      :token => password[i..j]
    )
    yield match, re_match
  end
end