|The problem with using a regex for this is that it gets very, very complex - and that means that when the rules change (and they always do) a horribly complicated and difficult to understand string has to be modified, tested, fixed, tested, and finally released. Which makes maintenance difficult and prone to error.
Instead, use .NET string operations (or individual Regexes) to pick up each individual part:
int numLoCase = ...
int numUpCase = ...
int numSpaces = ...
int numNumeric = ...
int numSpecial = ...
int len = ...And then apply a single
if statement to apply the rules:
if (len >= 10
&& len <= 50
&& numSpaces == 0
&& ...You get much more readable code, and more reliable maintenence.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!