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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 + 2 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2022 The PHP Group
All rights reserved.
Last updated: Sat May 28 04:06:34 2022 UTC