<?php function ote_accent($str){ $ch = strtr($str, 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy'); return $ch; } function check1($pattern,$Chaine){ if(preg_match($pattern,$Chaine)){ return " Chaine OK "; }else{ return "Chaine NON OK"; } } // /^[a-z0-9_-]*$/ pcre if(isset($_POST['tocheck']) && !empty($_POST['tocheck'])){ $chaine =$_POST['tocheck']; //$chaine=ote_accent($chaine); echo check1($pattern='/^[a-zA-Z 0-9_-]*$/',$chaine); //+ espace et majuscules }else{ echo $form = '<form method="post" action=""> test </form>'; } ?>
/^[a-z0-9_-]*$/
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionif (isset($_POST['tocheck']) && preg_match('`^[\w-]+$`', $_POST['tocheck'])) { echo 'Chaine OK'; } else { echo 'Chaine NON OK'; }