|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7222 ereg_replace, ereg
Submitted: 2000-10-15 11:46 UTC Modified: 2000-10-17 13:58 UTC
From: zibin at tx dot technion dot ac dot il Assigned:
Status: Closed Package: *Regular Expressions
PHP Version: 4.0.2 OS: unix
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: zibin at tx dot technion dot ac dot il
New email:
PHP Version: OS:


 [2000-10-15 11:46 UTC] zibin at tx dot technion dot ac dot il
everytime I have a regular expression which have ".*" or "[0-9]*" I get the following error:

Warning: REG_BADRPT in /home/websites/ on line 236

For example:
if ( eregi("onlyuser\[(.*?)\]",$inside, $regs) ||
if ( eregi("adduser\[(.*?)\]",$inside, $regs) ) {
But this doesn't cause error:
if ( eregi("authenticate=(.)",$inside, $regs) )
					$authenticate = $regs[1];

				if ( eregi("MUST Authenticate",$inside) )

thanks for your time.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2000-10-15 19:14 UTC]
I don't believe that this is a bug--those aren't valid POSIX regular
expressions. It looks like you're trying to use a perl-style non-greedy
operator (?) after the .* piece, which isn't part of the POSIX regex syntax.

For more information on POSIX regex syntax, check out the manual
page which comes with the PHP source--in PHP 4, it's located in
/path/to/php4/regex/regex.7. You can read it by doing something like:

% man /path/to/php4/regex/regex.7

If you want to use non-greedy type regexes, you should use the perl-
compatible functions; if you want to catch all of the instances found in a
string, use preg_match_all(). Something like this:

if (preg_match_all('/onlyuser\[(.*?)\]/i', $inside, $regs)) {

Check out and the
manual entries on syntax and pattern modifiers for more information.

 [2000-10-16 15:30 UTC]
Actually, the problem is in the escaping of the [ and ].

The first \ is being eaten by the PHP parser.

What you really want is

eregi("onlyuser\\\[(.*?)\\\]",$inside, $regs)
 [2000-10-17 13:58 UTC]
My mistake. My comments are only true in php 3.0.x
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 22:01:28 2024 UTC