$userName = 'us e';if(!(preg_match('/^[A-Za-z0-9\-_]{4,15}$/i', $userName))){echo 'error'; }else{echo 'Correcto';}