#49036 [Opn->Fbk]: preg_replace error when using \W
| From: | scottmac@php.net | Date: | Thu, 23 Jul 2009 17:41:11 +0000 |
| Subject: | #49036 [Opn->Fbk]: preg_replace error when using \W | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-140144@lists.php.net to get a copy of this message | ||
ID: 49036
Updated by: scottmac@php.net
Reported By: gvdefence-ncr at yahoo dot it
-Status: Open
+Status: Feedback
Bug Type: PCRE related
Operating System: WXP
PHP Version: 5.2.10
New Comment:
pcre is locale aware so there are some exceptions. What locale are you
using?
Also we use PCRE which is not the Microsoft regexp syntax, I suggest
you read the PHP manual instead.
Previous Comments:
------------------------------------------------------------------------
[2009-07-23 17:34:25] gvdefence-ncr at yahoo dot it
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 this bug report at http://bugs.php.net/?id=49036&edit=1