php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #8610 ereg* complains without cause
Submitted: 2001-01-09 03:51 UTC Modified: 2001-01-09 04:19 UTC
From: sam at ananova dot com Assigned:
Status: Closed Package: Regexps related
PHP Version: 4.0.4 OS: solaris 2.7
Private report: No CVE-ID: None
 [2001-01-09 03:51 UTC] sam at ananova dot com
if (eregi('^(ab|)c$',$x)) print "blah: $x<br>\n";

complains with 
Warning: REG_EMPTY in /usr/local/ananova_v2/www/search/_index.php on line 31

and returns false regardless of $x

yet:

echo "c" | egrep '^(ab|)c$'
echo "ac" | egrep '^(ab|)c$'
echo "abc" | egrep '^(ab|)c$'

outputs:
c
abc

Removing the from my php expression | stops the complaint but ruins the pattern.

My pattern intends to read (in english)
Optionally prefixed by "ab" and matches "c" exactly.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-01-09 03:53 UTC] sam at ananova dot com
Corrected bug type
 [2001-01-09 04:19 UTC] rasmus@php.net
I don't consider this a bug, and if you still think it is you will need to take it up with Henry Spencer.  According to Henry ab| is not valid as per Posix 1003.2.  Check out the php4/regex/tests file.  He specifically tests for this and says it should return EMPTY.  The workaround is to either use (ab|()) or use preg_match() instead.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Sep 17 17:01:28 2019 UTC