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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sam at ananova dot com
New email:
PHP Version: OS:

 

 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC