#49036 [NEW]: preg_replace error when using \W
| From: | gvdefence-ncr at yahoo dot it | Date: | Thu, 23 Jul 2009 17:34:27 +0000 |
| Subject: | #49036 [NEW]: preg_replace error when using \W | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-140143@lists.php.net to get a copy of this message | ||
From: gvdefence-ncr at yahoo dot it
Operating system: WXP
PHP version: 5.2.10
PHP Bug Type: PCRE related
Bug description: preg_replace error when using \W
Description:
------------
According to regexp sintax [\W] is identical to [^A-Za-z0-9_] (can see:
http://msdn.microsoft.com/en-us/library/1400241x(VS.85).aspx)
But preg_replace does not seem to work the same way.
Reproduce code:
---------------
<?php
//according to regexp sintax [\W] is identical to [^A-Za-z0-9_] (can
see: http://msdn.microsoft.com/en-us/library/1400241x(VS.85).aspx)
$result1 = preg_replace('/[^A-Za-z0-9_]*/', '', "test àèìòù
test");
$result2 = preg_replace('/[\W]*/', '', "test àèìòù test");
echo "<pre>" . $result1 . "</pre>"; //ok, it shows:
"testtest"
echo "<pre>" . $result2 . "</pre>" //wrong it shows:
"testàèìòùtest"
?>
Expected result:
----------------
testtest
testtest
Actual result:
--------------
testtest
testàèìòùtest
--
Edit bug report at http://bugs.php.net/?id=49036&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=49036&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=49036&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=49036&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=49036&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=49036&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=49036&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=49036&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=49036&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=49036&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=49036&r=support
Expected behavior: http://bugs.php.net/fix.php?id=49036&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=49036&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=49036&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=49036&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=49036&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=49036&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=49036&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=49036&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=49036&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=49036&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=49036&r=mysqlcfg