#49459 [NEW]: Use of case changing functions in preg_replace produces unexpected results
| From: | d dot reade at readesresidential dot com | Date: | Thu, 03 Sep 2009 16:00:24 +0000 |
| Subject: | #49459 [NEW]: Use of case changing functions in preg_replace produces unexpected results | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-141927@lists.php.net to get a copy of this message | ||
From: d dot reade at readesresidential dot com
Operating system: CentOS 5.3 x86
PHP version: 5.2.10
PHP Bug Type: Unknown/Other Function
Bug description: Use of case changing functions in preg_replace produces unexpected results
Description:
------------
Trying to use preg_replace to change text to uppercase in-between
<uc><uc>. However expected result doesn't occur and the text remains
lowercase. No errors are logged. However adding some text after $1 outputs
this text in uppercase, but the text in-between <uc><uc> remains as
lowercase.
Reproduce code:
---------------
<?
# Test 1: Attempt to replace 'my' with 'MY'
$text = 'this is <uc>my<uc> string';
$text = preg_replace('/\<uc\>(.*)\<uc\>/', strtoupper('$1'), $text);
echo $text.'<br><br>';
# Test 2: Add something after $1 which produces expected output
$text = 'this is <uc>my<uc> string';
$text = preg_replace('/\<uc\>(.*)\<uc\>/', strtoupper('$1 cool'),
$text);
echo $text;
?>
Expected result:
----------------
# Expected result for test 1
this is MY string
# Expected result for test 2
this is MY COOL string
Actual result:
--------------
# Actual result for test 1
this is my string
# Actual result for test 2
this is my COOL string
--
Edit bug report at http://bugs.php.net/?id=49459&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49459&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49459&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49459&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=49459&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49459&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=49459&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=49459&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=49459&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=49459&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=49459&r=support
Expected behavior: http://bugs.php.net/fix.php?id=49459&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=49459&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=49459&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=49459&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49459&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49459&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=49459&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=49459&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=49459&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=49459&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=49459&r=mysqlcfg