I'm not sure if a regular expression can handle the requirement, but a function just may be more readable anyway. Something like the below will eliminate anything with three consecutive equal characters or three consecutive characters that are follow an ascending or descending pattern of 1 (letters or numbers).
static bool IsPasswordRelativelyStrong(string input)
{
for (int i = 2; i < input.Length; i++)
{
if (input[i] == input[i - 1] - 1 && input[i - 1] == input[i - 2] - 1)
return false;
else if (input[i] == input[i - 1] + 1 && input[i - 1] == input[i - 2] + 1)
return false;
else if (input[i] == input[i - 1] && input[i - 1] == input[i - 2])
return false;
}
return true;
}
So given the following array
string[] passwords = { "123456", "abcde", "654321", "111223", "11223344" };
Only the final one passes. The function could be expanded to consider whether or not you allow and/or require non-alphanumeric characters and whether a password must exceed a minimum length requirement.