Justin French <[EMAIL PROTECTED]> wrote:
> If you care about performance at all, try and find away around the
> problem without regular expressions...
>
> I tested
>
> if( (strlen($str) == 6) && (is_int($str)) )
>
> vs
>
> if(ereg('^[0-9]{6}$',$str))
>
>
> ...on my LAN test server with 100000 iterations, and the regexp was
> nearly 2 times slower than the first solution. IMHO, it's also faster
Excellent point! I find my self using regex's a bit to often when there
are other solutions available.
btw, have you ever tested the difference between
if(ereg('^[0-9]{6}$',$str))
if(preg_grep('^[0-9]{6}$',$str))
I've been meaning to find out advantages/disadvantages with PERL vs.
POSIX compatible.
Curt.
--
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php