|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-08-28 16:22 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 12:00:02 2025 UTC |
* 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");