|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25700 PCRE_ANCHORED doesn't work
Submitted: 2003-09-30 05:03 UTC Modified: 2003-09-30 10:53 UTC
Avg. Score:4.0 ± 1.4
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: php at bouchery dot com Assigned:
Status: Not a bug Package: PCRE related
PHP Version: Irrelevant OS: all
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: php at bouchery dot com
New email:
PHP Version: OS:


 [2003-09-30 05:03 UTC] php at bouchery dot com
PCRE_ANCHORED option dosn't work

Reproduce code:
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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-30 07:02 UTC] php at bouchery dot com
In fact, "A" option is equal to "^" + patern.
If I don't misunderstand, "A" option should be equal to "^" + patern + "$"
 [2003-09-30 08:44 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:
(the section about A (PCRE_ANCHORED))

 [2003-09-30 10:05 UTC] php at bouchery dot com
Sorry, it's a mistake in the french documentation !
"it is constrained to match between the start to the end of the string"

Thus, it's a bug in the documentation's translation.
 [2003-09-30 10:53 UTC]
The french translation have been fixed in CVS, no need to open a new bug. sorry for the time wasted...

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu May 19 00:04:05 2022 UTC