Well ...

- the {7,9} means that the previous char/group should repeat 7 to 9 times
...
- ^ means the beginning of the string
- $ means the end of the string

So everything, that validates, is 7 to 9 numbers.

"123456789 This is a test" won't validate - it contains chars instead of $
(end of string) after [0-9]{7,9} = 7 to 9 numbers.

And yes, you can use something like [[:digit:]] but I must admit I don't use
that much.

Ales

<[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
.
> > if(ereg("^[0-9]{7,9}$", $_REQUEST["icqnumber"])) {
> > >> print("a-okay!");
> > >> } else {
> > >> print("error msg");
> > >> }
>
> Although I'm not too familiar with regexp I'd say the code validates
> because the icq number you are providing actually confimrs to the pattern.
> The first seven to nine digits contain only numbers so the pattern is
> true. Th ce pattern does not check the length of your provided string.
> If I'm correct than "123456789 This is a test" will also proof to be
> correct. So you have to do two things first check the whole argument for
> digits like ereg('^[0-9]{'.strlen($_REQUEST['icqnumber']).'}',
> $_REQUEST['icqnumber']) and check length separatly. (U can also use
> [[:digit:]]) Or use the code as mentioned before.
> In your place I would not assume anything about the length of the icq
> number.
>
> Hope that helps
> Stefan
>
> P.S.: Please correct me if I'm wrong with the above!!!!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to