Password: it must contain only numbers and letters, 6-10 characters. How to write a regular expression? Solution ...... share to: more-Password: must contain only numbers and letters, 6-10 characters. How to write a regular expression?
Solving ............
Share: More
------ Solution --------------------
$ Pattern = '/^ [a-zA-Z0-9] {6, 10} $ /';
------ Solution --------------------
$ Pattern = '/^ (?! [0-9] + $ )(?! [A-zA-Z] + $) [0-9A-Za-z] {6, 10} $ /';
Separate the following comments:
^ Match the starting position of a row
(?! [0-9] + $) predicting that the position is not followed by all numbers
(?! [A-zA-Z] + $) predict that the position is not followed by all letters
[0-9A-Za-z] {6, 10} consists of 6-10 digits or the letter
$ Match the end of a row
------ Solution --------------------
If (preg_match ('/\ d +/', $ s) & preg_match ('/[a-z] +/I', $ s )){
Echo 'yes ';
} Else {
Echo 'no ';
}