dipen baks dipen baks - 1 year ago 108
Swift Question

Swift - password validation : Can anyone tell me what type of password this line wants?

let emailRegEx = "^(?=.*?[0-9])(?=.*?[#?!@$%^&*-]).{8,}$"
let passwordTest = NSPredicate(format:"SELF MATCHES %@",emailRegEx)
let result = passwordTest.evaluateWithObject(testStr)
return result

This is the code for my password validation function, can anyone tell me the meaning of it.

Answer Source
  • (?=.*?[0-9]) - At least One digit.

  • (?=.*?[#?!@$%^&*-]) - At least one special symbol from Specific set of allowed Special symbols(#?!@$%^&*-).

  • .{8,} - At least 8 characters.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download