par
stealth35 » 02 juil. 2010, 03:39
avec un regexp
sois
$str = 'tesdsxwcw$.sfsf'';
$reg = '/^[a-z\$\.]{8,32}$/';
preg_match($reg, $str, $matches);
if($matches)
{
echo 'yep';
}
else
{
echo 'nope';
}
ou plus officiel
$str = 'tes';
$reg = '/^[a-z\$\.]{8,32}$/';
$filter = filter_var($str, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $reg)));
if($filter)
{
echo 'yep';
}
else
{
echo 'nope';
}
avec un regexp :wink:
sois
[php]
$str = 'tesdsxwcw$.sfsf'';
$reg = '/^[a-z\$\.]{8,32}$/';
preg_match($reg, $str, $matches);
if($matches)
{
echo 'yep';
}
else
{
echo 'nope';
}[/php]
ou plus officiel
[php]
$str = 'tes';
$reg = '/^[a-z\$\.]{8,32}$/';
$filter = filter_var($str, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $reg)));
if($filter)
{
echo 'yep';
}
else
{
echo 'nope';
}[/php]