Regular expression

1

Regular expression for a password validation. I want it to be possible at least a lowercase letter, a capital letter, at least a number and special characters (/, _, -, ...). Example: $regex = '#^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$#';

How can I add more special characters?

    
asked by anonymous 09.02.2017 / 12:12

2 answers

6

In the middle 8 letters, at least one Tiny, at least one Lowercase, at least 1 Number and accepting special:

^(?=.*[a-zç])(?=.*[A-ZÇ])(?=.*\d)[\S\s]{8,}$

Here you have a link to tests EXTERNAL .

    
09.02.2017 / 12:22
2

You already have almost all of it, just change the ending:

#^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d_ /.-]{8,}$# .

Remembering that \w is a summary for [a-zA-Z0-9_] .

Looking like this:

#^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[\w /.-]{8,}$# .

    
09.02.2017 / 13:54