ereg Confusion
| From: | Jamie Alessio | Date: | Mon, 06 Nov 2000 19:26:08 +0000 |
| Subject: | ereg Confusion | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-23965@lists.php.net to get a copy of this message | ||
I need to validate user input for tags that are in the format of "ME-xxxxx" where
'x' is
numeric. The input needs to start with "ME-" and then have 5 numbers. I created the
following regular expression but I am not getting the results I would expect. It evaluates
false if I change the "ME-" or put any non-numeric value after "ME-" but it
still
evaluates true if there are more than five numbers after "ME-".
-- Evaluates TRUE
$value = "ME-12345";
ereg("ME-([0-9]{5,5})", $value)
-- Evaluates FALSE
$value = "ME-1X345";
ereg("ME-([0-9]{5,5})", $value)
-- Evaluates True
$value = "ME-123456789012345678";
ereg("ME-([0-9]{5,5})", $value)
Am I missing something? This seems like it should produce the desired results.
Config:
PHP 4.0.2
FreeBSD 4.1
Apache 1.3.12
Thanks.
- Jamie