[PHP-DEV] PHP 4.0 Bug #7222 Updated: ereg_replace, ereg From: Bug Database (php-dev <email protected>)
Date: 10/15/00

ID: 7222
Updated by: torben
Reported By: zibin <email protected>
Status: Closed
Bug Type: *Regular Expressions
Assigned To:
Comments:

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)) {
    var_dump($regs);
}

Check out http://www.php.net/manual/function.preg-match-all.php and the
manual entries on syntax and pattern modifiers for more information.

Previous Comments:
---------------------------------------------------------------------------

[2000-10-15 11:46:56] zibin <email protected>
everytime I have a regular expression which have ".*" or "[0-9]*" I get the following error:

Warning: REG_BADRPT in /home/websites/www.gigcenter.com/DB.htmlToPHP3.php3 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.

---------------------------------------------------------------------------

Full Bug description available at: http://bugs.php.net/?id=7222

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>