Here is a link to a website im using to validate and check the regex is working : https://regex101.com/
Here is the regex im using so far :
/(?=[\x21-\x7e]{8,20})(?=[^0-9]*[0-9])(?=[^a-z]*[a-z])(?=[^A-Z]*[A-Z]).*/g
Heres the text im testing :
"1abcderfggdgf sdvhbsdifsdfsdf1 Ghhuidicbdbuhbdc bhdbcdbebvuheY uuvvvyuv1G 1Guhuuuyuyuby Y%*&^$^%^(^(GVGVYUKVYTUHBKBUFygyygyg
ebfuiuberiueu23423HHII"
This is what i think this is doing :
- Looking to match any ascii character between 33 and 126 indexed and is between 8-20 in length
- look for a non number that precedes a number 0 or more times (from what ive read apparently this detects if there is a number present)
- Check for lower case letter that is preceded my 0 or more non lower case letters.
- do the same thing ^^ with upper case letters
- throw it an any character using ".*" 0 or more times because with the look aheads they should narrow it down so not every character is allowed and it should match what the look aheads select
This is what I want it to do :
validate passwords that follow these specifics -
- Must have at least 1 lowercase letter
- Must have at least 1 uppercase letter
- Must have at least 1 number
- can only be between and including 8 - 20 characters in length
- characters can only be from and including 33 to 126 in ascii NOT including white-space characters (where did i get this from? - https://kb.wisc.edu/page.php?id=4073)
Extra Notes :
Ive been using the global (?thing) on the end of the regex to specify not to stop at the first match I think for my password field I dont need this because it should only be limited to 20 characters anyway.(im not sure about this)
also itd be cool to detect whether a character has been used consecutively more then 3 times but its not necessary at the moment.
The password is input to a form in my php file. Im trying to use this as a validator for an input tag.
there is no code to not allow spaces as of yet.