PHP 4.0 Bug #7222 Updated: ereg_replace, ereg

From: Date: Sun, 15 Oct 2000 23:14:22 +0000
Subject: PHP 4.0 Bug #7222 Updated: ereg_replace, ereg
Groups: php.dev 
Request: Send a blank email to php-dev+get-35076@lists.php.net to get a copy of this message
ID: 7222 Updated by: torben Reported By: zibin@tx.technion.ac.il 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@tx.technion.ac.il 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

« previous php.dev (#35076) next »