Bug #52723 [Opn->Bgs]: Something wrong with preg_replace

From: Date: Sat, 28 Aug 2010 14:37:53 +0000
Subject: Bug #52723 [Opn->Bgs]: Something wrong with preg_replace
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-153872@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52723&edit=1 ID: 52723 Updated by: rasmus@php.net Reported by: clark21330 at gmail dot com Summary: Something wrong with preg_replace -Status: Open +Status: Bogus Type: Bug Package: Scripting Engine problem Operating System: Win Server 2008 PHP Version: 5.2.14 Block user comment: N New Comment: * doesn't mean what you think it does in a regular expression. You want a + there. Like this: echo preg_replace("/([a-zA-Z0-9])+/","1","a"); Previous Comments: ------------------------------------------------------------------------ [2010-08-28 16:22:44] clark21330 at gmail dot com Description: ------------ you see,I just need one 1 in the return value,but,where did the second "1" come from? I use ([a-zA-Z0-9])* to match all numbers and letters, and I just using only one "a" as the input parameter But how can the return value be the "double 1"? Test script: --------------- echo preg_replace("/([a-zA-Z0-9])*/","1","a"); Expected result: ---------------- 11 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52723&edit=1

« previous php.bugs (#153872) next »