Also, don't forget to escape the $ character in your expression, since it is
reserved for variable declaration.
"Ales KrajníK" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
> Well ...
>
> - the {7,9} means that the previous char/group should repeat 7 to 9 times
> ...
> - ^ means t
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
Does it actually NEED a regexp?
UNTESTED code:
7) && (strlen($icq) < 9) ) {
echo "yah";
} else {
echo "nah";
}
?>
FWIW, Are you SURE that all valid ICQ #'s are between 7 and 9 chars?
Surely at some point they'll reach 10 chars, and *may* have started at 6?
Justin
on 04/03/03 6:00 AM
On Mon, 3 Mar 2003 14:00:43 -0500, you wrote:
>Maybe I'm off my rocker, but I don't see how this can't work. I'm trying to validate
>an ICQ number, and assuming a valid one is between 7 and 9 numbers. My line of code
>is this:
>
>if(ereg("^[0-9]{7,9}$", $_REQUEST["icqnumber"])) {
>print("a-o
Use single quotes around your pattern.
if(ereg('^[0-9]{7,9}$',...
With the double quotes, PHP is probably seeing the $ and looking for a
variable, even though it's at the end of the string.
---John Holmes...
- Original Message -
From: "Liam Gibbs" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECT
5 matches
Mail list logo