cucumber Posted August 2, 2006 Report Share Posted August 2, 2006 preg_match, vai ir iespejams uzrakstit, tadu masku, kas skatas vai varda ir kaut >=1 lielais burts, >=1 mazais burts, 1>= cipars tas ir qwertY123 -> ok Qwery123 -> ok 1Q3asdffa -> ok qwerty123 - wrong Qwertyaf - wrong utt. ? Link to comment Share on other sites More sharing options...
v3rb0 Posted August 2, 2006 Report Share Posted August 2, 2006 (edited) piečuks no tevis :p $ex = '/([a-z]{1,}[A-Z]{1,}[0-9]{1,})|'; $ex .= '([a-z]{1,}[0-9]{1,}[A-Z]{1,})|'; $ex .= '([0-9]{1,}[A-Z]{1,}[a-z]{1,})|'; $ex .= '([0-9]{1,}[a-z]{1,}[A-Z]{1,})|'; $ex .= '([A-Z]{1,}[0-9]{1,}[a-z]{1,})|'; $ex .= '([A-Z]{1,}[a-z]{1,}[0-9]{1,})/'; foreach(array('qwertY123','Qwery123','1Q3asdffa','qwerty123','Qwertyaf') as $str) { echo '<br />'.$str; if(preg_match($ex, $str)){echo ' OK';} else { echo ' WRONG';}; } Edited August 2, 2006 by v3rb0 Link to comment Share on other sites More sharing options...
bubu Posted August 2, 2006 Report Share Posted August 2, 2006 {1,} ir tas pats, kas + Link to comment Share on other sites More sharing options...
cucumber Posted August 2, 2006 Author Report Share Posted August 2, 2006 samera sarezgiti sanak, vieglak laikam ir: if (preg_match("/[a-z]/",$someword) ) $a=1 if (preg_match("/[A-Z]/",$someword) )$b=1 if (preg_match("/[0-9]/",$someword) )$c=1 if ($a==1 && $b==1 && $c==1) echo ("OK"); Link to comment Share on other sites More sharing options...
bubu Posted August 2, 2006 Report Share Posted August 2, 2006 cucumber: un ja nu tekstā būs kautkas cits. Tu jau sākumā to neatļāvi. Link to comment Share on other sites More sharing options...
Recommended Posts