Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>We have the following regex: <code>/^(\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*){6,20}$/</code></p> <ol> <li><p>The first and last <code>/</code> are the delimiters.</p></li> <li><p><code>^</code> -> The start, <code>$</code> -> The end</p> <p>Which means if input is <code>abc</code> and your regex is <code>/^bc$/</code>, it won't get matched since bc is not at the beginning.</p></li> <li><p>Now we have <code>(\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*){6,20}</code></p> <p>The <code>{6,20}</code> is the quantifier part, which means 6 up to 20 times.</p></li> <li><p>Let's break the regex further: <code>\w*(?=\w*\d)(?=\w*[a-z])(?=\w*[A-Z])\w*</code></p> <p>Let's provide some equivalents:</p> <ol> <li><code>\w</code> => [a-zA-Z0-9_]</li> <li><code>\d</code> => [0-9]</li> <li><code>*</code> => zero or more times</li> <li><p><code>(?=)</code> Is a lookahead assertion. Example <code>/a(?=b)/</code> this will match any "a" followed by "b"</p></li> <li><p>The purpose of those lookaheads:</p> <ul> <li><code>(?=\w*\d)</code> => check if there is a digit</li> <li><code>(?=\w*[a-z])</code> => check if there is a lowercase letter</li> <li><code>(?=\w*[A-Z])</code> => check if there is a uppercase letter</li> <li>Let's take <code>(?=\w*\d)</code>: The <code>\w*</code> is just there as a "workaround" in case there is [a-zA-Z0-9_]* before a digit</li> </ul></li> </ol></li> </ol> <p>In the end, this regex just makes sure that the input:</p> <ol> <li>is 6 to 20 characters long</li> <li>that there is minimal: 1 lowercase, 1 uppercase and 1 digit</li> <li>that the allowed characters are letters (upper and lowercase (a-z,A-Z)), digits and underscore.</li> </ol> <p>Three interesting sites <a href="http://www.regexper.com/" rel="nofollow noreferrer">www.regexper.com</a>, <a href="http://www.regular-expressions.info/" rel="nofollow noreferrer">www.regular-expressions.info</a> and <a href="http://www.regex101.com" rel="nofollow noreferrer">www.regex101.com</a>.</p> <p><strong>Note:</strong> Don't restrict passwords, you have to hash them anyway. Take a look <a href="https://stackoverflow.com/q/401656">here</a> or check the other questions on SO.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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