"Sp" <[EMAIL PROTECTED]> wrote in message
> I am trying to validate my input with ereg but I get the error "Warning:
> REG_BADBR" when I try over 255 characters.  Is there anyway around this?
> Works
> =====
> if(eregi('^[A-Za-z]{1,255}$', "test sentence"))
>   echo "valid input";
> Doesn't Work
> ============
> if(eregi('^[A-Za-z]{1,256}$', "test sentence"))
>   echo "valid input";

First off, you're using eregi (case insensitive), but defining a-zA-Z (a
through z, case insensitive) in your characters class. You could just use
ereg and leave the character class as it is, or drop the A-Z from the eregi

Secondly, I'd amend your code to:

And thirdly, I'd just use a combination of ereg / preg_* functions and

if(preg_match("/^[a-z]+$/i", $string) && strlen($string) < 255)
    echo "Whatever.";

I'm not sure why you're getting that error, but then again, I haven't
bothered reading up about it :)


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

Reply via email to