Ereg bug?
| From: | Lee Willis | Date: | Mon, 04 Sep 2000 16:09:39 +0000 |
| Subject: | Ereg bug? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-15149@lists.php.net to get a copy of this message | ||
I'm having problems with some eregs/pregs in PHP 4.0.1p2 and I wanted to
post them here to check I wasn't being dumb before reporting this as a
bug.
The following code:
<?
if (ereg ('^\\(.*)', '\abc', $matches)) {
while (list ($key, $value) = each ($matches)) {
echo "$key = $value<BR>";
}
} else {
echo "REGEX didn't match.";
}
?>
Reaches the "else" clause even though I would have thought it would
match.
Another more complicated example (Which is closer to what I was trying
to do ...) is:
<?
if (ereg ('^[^\]\{(.*)[^\]\}', '{abc}', $matches)) {
while (list ($key, $value) = each ($matches)) {
echo "$key = $value<BR>";
}
} else {
echo "REGEX didn't match.";
}
?>
Which I think should match a {} enclosed string as long as there is no \
before both the { and }
It doesn't. These *seem* to be bugs in PHP/regex library but I'd be
grateful if anyone can check them over and check it's not just me being
dumb, and maybe even explain where I'm going wrong ...
Thanks
Lee
--
| Lee Willis Fixed cost Internet access available @
| Application Developer http://www.plus.net
| PlusNet Technologies Ltd
+---------------"PlusNet - The smarter way to Internet"----------------