dipen baks dipen baks - 1 month ago 15x
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.

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

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

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