php.net |  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
Votes:3
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at bouchery dot com
New email:
PHP Version: OS:

 

 [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

Patches

Pull Requests

History

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] sniper@php.net
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))

 [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] didou@php.net
The french translation have been fixed in CVS, no need to open a new bug. sorry for the time wasted...

http://cvs.php.net/diff.php/phpdoc-fr/reference/pcre/functions/pcre.pattern.modifiers.xml?login=2&r1=1.2&r2=1.3&ty=u

didou
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 05:01:27 2025 UTC