brewersfan1976

password_check_reg_exp.rb

Jun 11th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.80 KB | None | 0 0
  1. def passwordCheckRegExp(inputString)
  2.     if inputString.length < 5 then
  3.        return false
  4.     end
  5.        
  6.     x = 0
  7.     capital_letter = false
  8.     small_letter = false
  9.     digit = false
  10.        
  11.     while (x < inputString.length)
  12.           if inputString[x] >= 'A' and inputString[x] <= 'Z' then
  13.              capital_letter = true
  14.           end
  15.            
  16.           if inputString[x] >= 'a' and inputString[x] <= 'z' then
  17.              small_letter = true
  18.           end
  19.              
  20.           if inputString[x] >= '0' and inputString[x] <= '9' then
  21.              digit = true
  22.           end
  23.              
  24.           x = x + 1
  25.     end
  26.              
  27.     if capital_letter == true and small_letter == true and digit == true then
  28.        return true
  29.     else
  30.        return false
  31.     end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment