Note that there are some explanatory texts on larger screens.

plurals
  1. POChecking strings for a strong enough password
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/3131025/strong-password-regex">Strong password regex</a><br> <a href="https://stackoverflow.com/questions/5142103/need-regex-for-password-strength">Need RegEx for password strength?</a> </p> </blockquote> <p>I was just wondering what the best way to search a string for certain criteria (password strength to be specific) could be accomplished.</p> <p>So far I have a simple:</p> <pre><code>if(password.Length &lt;= 7) { errorMessage = "Your password must be at least 8 characters."; } </code></pre> <p>I would like to be able to check for capital letters, but I am not sure what the method or procedure is. I have tried Googling, searching the website: <a href="http://msdn.microsoft.com" rel="noreferrer">http://msdn.microsoft.com</a>, and searching the index of my C# book (C# Programming 3E, by Barbara Doyle), but I can't seem to find any.</p> <p>I know I could try this...:</p> <pre><code>foreach(char c in password) { if(c!='A' || c!='B' || c!='C' || c!='D' ..... || c!='Z') { errorMessage = "Your password must contain at least one capital letter"; } } </code></pre> <p>...But that would be extremely sloppy, and would have to be doubled to check for at least one lowercase letter. I am sure there is a better way to do this, or at least shorthand for the method I have shown above.</p> <p>Also, I may decide to check the password for special characters (seems easier to do in the example above than with upper and lower case letters, so I may just use that for special characters, should I decide to make them necessary). If there is an easy (or proper) way to do that, I would love to have that knowledge, as well.</p> <p>Anyway, thank you so much for any help anyone can give.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload