Say I have a regex that checks for alphanumeric.
I now want to create another regex that checks for at least 1 number in the password.
And I want to check if it has at least 1 non-alphanumeric character (somethign other than a letter or number).
Should I just call each one seperatley, and if one fails return false or is there a way to combine them into 1 call?
Depends on exactly what criteria you’re using, but it would probably be better to do a single pass through the string and set a number of flags based on what you’ve seen:
Then use these at the end to decide if the password is complex enough.
Even Better:
As lexu suggests, using counts instead of flags would allow greater flexibility.