1."/([A-Za-z]+)([0-9]+)([-_]+)|\\1\\3\\2|\\2\\1\\3|\\2\\3\\1|\\3\\1\\2|\\3\\2\\1/is"
2.
$a = '[a-z]+';
$b = '[0-9]+';
$c = '[-+_!@#$%^&*()]+';
$p = "/$a$b$c|$a$c$b|$b$a$c|$b$c$a|$c$a$b|$c$b$a/";
$ar = array(
'12ab_',
'a1b2c45',
'&23a4c',
'a12s*d43',
);
foreach($ar as $v) {
echo $v . " : ";
echo preg_match_all($p, $v, $r) ? 'ok' : 'err';
echo '<br>';
}
3.(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z]).{6,16}
4.分两步吧
第一步[A-Za-z]
第二步
^[A-Za-z0-9]{4,20}$
5.^(?![0-9]+$)[a-zA-Z0-9]{4,20}$ |