|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-09-30 05:03 UTC] php at bouchery dot com
Description:
------------
PCRE_ANCHORED option dosn't work
Reproduce code:
---------------
<?php
echo preg_match( '`[a-z]{4}`A', 'fred24' ) ? 'ok' : 'ko';
?>
Expected result:
----------------
option "A" must return "ko"
Actual result:
--------------
Return "ok" and it's wrong
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 18:00:01 2025 UTC |
You misunderstood: echo preg_replace("/[a-z]{4}/A", "foo", "1fred24"); -> 1fred24 echo preg_replace("/[a-z]{4}/A", "foo", "fred24"); -> foo24 echo preg_replace("/[a-z]{4}/", "foo", "fred24"); -> foo24 echo preg_replace("/[a-z]{4}/", "foo", "1fred24"); -> 1foo24 See also this: http://www.php.net/manual/en/pcre.pattern.modifiers.php (the section about A (PCRE_ANCHORED))