I have to make a regex for a password with the following conditions: - minimum 4 characters - at least 1 non-word character.
I tried this way:
$regex_password = '@(\W)+@';
$regex_password1 = '@(?i)([a-z\d])+@';
if ((!preg_match($regex_password, trim($_POST['pass']))) && (!preg_match($regex_password1, trim($_POST['pass']))) && strlen(trim($_POST['pass'])) <5){
//error
}
And then tried to create a new account with the password: "pas" and it's working, so there's something wrong with my regex. Can someone help?