Req #81469 [NEW]: preg_replace(): add support for named capture groups

From: Date: Thu, 23 Sep 2021 13:01:44 +0000
Subject: Req #81469 [NEW]: preg_replace(): add support for named capture groups
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236777@lists.php.net to get a copy of this message
From: wim at squeezely dot tech Operating system: PHP version: Irrelevant Package: PCRE related Bug Type: Feature/Change Request Bug description:preg_replace(): add support for named capture groups Description: ------------ Would it be possible to add support for named capture groups to preg_replace()? php > var_dump(preg_replace('/([a-z]+)$/', 'ice-cream-with-${1}', 'I-like-chocolate-sprinkles')); string(41) "I-like-chocolate-ice-cream-with-sprinkles" Add support for: var_dump(preg_replace('/(?<namedGroup>[a-z]+)$/', 'ice-cream-with-${namedGroup}', 'I-like-chocolate-sprinkles')); Test script: --------------- php > var_dump(preg_replace('/(?<namedGroup>[a-z]+)$/', 'ice-cream-with-${namedGroup}', 'I-like-chocolate-sprinkles')); Expected result: ---------------- string(41) "I-like-chocolate-ice-cream-with-sprinkles" Actual result: -------------- string(45) "I-like-chocolate-ice-cream-with-${namedGroup}" -- Edit bug report at https://bugs.php.net/bug.php?id=81469&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81469&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81469&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81469&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81469&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81469&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81469&r=support Expected behavior: https://bugs.php.net/fix.php?id=81469&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81469&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81469&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81469&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81469&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81469&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81469&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81469&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81469&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81469&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81469&r=mysqlcfg

« previous php.bugs (#236777) next »