Allow special characters such as @ #% & - + () / * "':;!? | ~ {} [] _ in password

3

What regular expression can I use to allow characters like these @#%&-+()/*"':;!?~|{}[]_ in php?

    
asked by Eddy Otsutsuki 03.07.2016 в 08:00
source

1 answer

4

With this regular expression you are forced to:

The password must have between 8 and 16 characters, at least one digit, at least one lowercase, at least one uppercase and at least one non-alphanumeric character.

^(?=.*\d)(?=.*[\u0021-\u002b\u003c-\u0040])(?=.*[A-Z])(?=.*[a-z])\S{8,16}$

the code in PHP

if (preg_match('/^(?=.*\d)(?=.*[\u0021-\u002b\u003c-\u0040])(?=.*[A-Z])(?=.*[a-z])\S{8,16}$/', $cadenaok))
{
    return true;
}
    
answered by 03.07.2016 / 09:48
source