note 18877 added to function.ereg-replace
| From: | roland at inkoeln dot com | Date: | Fri, 08 Feb 2002 06:22:47 +0000 |
| Subject: | note 18877 added to function.ereg-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-26372@lists.php.net to get a copy of this message | ||
ereg_replace can't do minimal matching (+? and *?). Example:
$txt = 'a=b=c';
$a = ereg_replace('.+(=.+)', 'x\1', $txt);
$b = preg_replace('/.+?(=.+)/', 'x$1', $txt);
print "$a, $b";
the result is: x=c, x=b=c
because of the more powerful perl compatible regexp-syntax you should always prefer preg_replace
(and preg_match).
--
http://www.php.net/manual/en/function.ereg-replace.php
http://master.php.net/manage/user-notes.php?action=edit+18877
http://master.php.net/manage/user-notes.php?action=delete+18877
http://master.php.net/manage/user-notes.php?action=reject+18877