The below regex requires that the password has 1 number, 1 char (upper or lower) and is a minimum of 8 in length. But if I type in a special char it returns false. I don’t want to require a special char, but i want to allow it in this context. How can I alter this regex to allow a special char?
Regex.IsMatch(Password, "^(?=.*[0-9])(?=.*[a-zA-Z])\w{8,}$")
Changing “\w” to “.” should do it:
\w matches “word” characters, which won’t normally match special characters (depending on your definition of “special” and the language you’re using).
. will match any character except newline