[php-src] Issue #11255: Strange result of preg_replace

From: Date: Wed, 17 May 2023 09:25:56 +0000
Subject: [php-src] Issue #11255: Strange result of preg_replace
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244469@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11255 Author: houssemz ### Description The following code: ```php <?php $search = [ "/^.*de\.seeandso\.com/i", "/^.*\.seeandso\.com/i", ]; $replace = [ "local-de.seeandso.com", "local.seeandso.com", ]; $str = preg_replace($search, $replace, "https://de.seeandso.com/foo", 1, $count); echo $str, PHP_EOL; echo $limit, PHP_EOL; ``` ``` Resulted in this output: ``` $str === "local.seeandso.com/foo" // and not "local-de.seeandso.com/foo" $count === 2 // even with limit === 1 ``` But I expected this output instead: ``` $str === 'local-de.seeandso.com/foo' ``` ### PHP Version PHP 7, PHP 8 ### Operating System macOS Monterey 12.6.3

« previous php.bugs (#244469) next »