In article <94t6hv$903$[EMAIL PROTECTED]>, "Kumanan"
<[EMAIL PROTECTED]> wrote:
if (eregi("[^0-9]{3}",$co_area)) {
print("area code must be digits");
}
or
if (eregi("[^[:digit:]]{3}",$co_area))
if you use the POSIX regex fields.
> hi, im trying to fix this couple of hours but i couldnt find the
> mistake... can somebody look at it...
>
> first i want to check the $co_area for 3 digital ... it must contain 3
> digital
>
> if ($co_area != !ereg("([0-9]{3})",$co_area))
> { echo " * Area code must be 3 digital"; }
>
>
> second...
>
> nickname check works but the first letter could be any number or any
> letters....
>
> with this code it accept only letters as first character....... i just
> want any letter or numbers or - _ symboles from 3 to 12 characters...
>
> if ($nickname != !eregi("^[-\._\.0-9a-zA-Z]{3,12}$",$nickname))
> {
> $error ="Nickname must be Alphanumeric[ a-z 0-9; - _ ; 3 - 12
> characters ]";
> $flak=1;
> }
>
First mistake when using character classes in the pattern is that the
hyphen must be at the end if it is to be included. Otherwise the hyphen
is seen to be part of the range (0-9 or A-Z):
so, ^[0-9a-zA-Z._-]{3,12}
instead of what you have. You also should not need the trailing $.
As in the first example, don't use the 'double negative' approach.
use:
if (eregi("^[^0-9a-zA-z._-]{3,12}",$nickname)) {
echo "only alphanumeric buddy!";
}
I didn't test this but it should be closer to success.
Jeff
>
> i hope someone can help me to fix this...
>
> thanx
>
> kumanan [EMAIL PROTECTED]
>
>
>
>
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]