Advertisement
brewersfan1976

password_check_reg_exp.rb

Mar 30th, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.02 KB | None | 0 0
  1. def passwordCheckRegExp(inputString)
  2.     capital = false
  3.     small = false
  4.     digits = false
  5.     characters = false
  6.    
  7.     x = 0
  8.    
  9.     if inputString.length >= 5 then
  10.        characters = true
  11.     end
  12.        
  13.     while (x < inputString.length)
  14.           if inputString[x] >= 'A' and inputString[x] <= 'Z' then
  15.              capital = true
  16.           end
  17.                  
  18.           x = x + 1
  19.     end
  20.            
  21.     x = 0
  22.            
  23.     while (x < inputString.length)
  24.           if inputString[x] >= 'a' and inputString[x] <= 'z' then
  25.              small = true
  26.           end
  27.                
  28.           x = x + 1
  29.     end
  30.        
  31.     x = 0
  32.        
  33.     while (x <inputString.length)
  34.           if inputString[x] >= '0' and inputString[x] <= '9' then
  35.              digits = true
  36.           end
  37.              
  38.           x = x + 1
  39.     end
  40.        
  41.     if characters == true and capital == true and small == true and
  42.        digits == true then
  43.        return true
  44.     else
  45.        return false
  46.     end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement