What is the maximum length you can check a regular expression on.
[a-z0-9 ]{1,50}$ = Works fine
[a-z0-9 ]{1,200}$ = Gives errors
so how do you checki strings that are over 200 chars in length??
Leave out the length restraint and just say that it has to be alphanumeric. Unless you are expecting some non alphanumeric values later on in the string? Rob
I dont want it to be less than 1 in length, and i dont want it to be more than 300 chars in length. so what do i do??
The do it like this
[a-z0-9 ]+$
The plus says that there must be at least one occurance of this Also this will only match lower case letters, is this right? Good Luck Rob
yes its right but it still doesnt give me the maximum length.
you could use that regex and then do if(strlen($string)<$maxLength) { echo("error: The string was too long"); } else { //continue with script }
hope this helps Rob
obviously ereg seems to have some limit - I normally don't use it, but it shows the behaviour you described.
however, preg_match() doesn't and
preg_match(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to ereg().
(just for the record, error message reads: Warning: ereg() [function.ereg]: REG_BADBR: ...)