php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46184 a problem with internal vars
Submitted: 2008-09-26 15:38 UTC Modified: 2008-09-28 10:11 UTC
From: vasilkov80 at mail dot ru Assigned:
Status: Not a bug Package: PCRE related
PHP Version: 5.2.6 OS: linux mandriva 2007
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: vasilkov80 at mail dot ru
New email:
PHP Version: OS:

 

 [2008-09-26 15:38 UTC] vasilkov80 at mail dot ru
Description:
------------
a problem with internal vars?

/\"([^\"]+\.jpg)\"/ - the pattern works fine...
/([\"\'])([^\\1]+\.jpg)\\1/ - a bit more complex pattern doesn't work as expected!

Reproduce code:
---------------
if( preg_match("%([\"\']{1})([^\\1]+\.jpg)\\1%", '.. "bla bla "image.jpg" .. " bla bla', $matches) )
	print_r($matches);

Expected result:
----------------
Array
(
    [0] => "image.jpg"
    [1] => image.jpg
)

Actual result:
--------------
Array
(
    [0] => "bla bla "image.jpg"
    [1] => "
    [2] => bla bla "image.jpg
)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-26 15:44 UTC] vasilkov80 at mail dot ru
sorry, expected result:

Array
(
    [0] => "image.jpg"
    [1] => "
    [2] => image.jpg
)
 [2008-09-28 10:11 UTC] nlopess@php.net
your regex is wrong.

quote from the PCRE manual:
"Outside a character class, a backslash followed by a digit greater than 0 (and possibly further digits) is a back reference to a capturing sub-pattern  earlier  (that is, to its left) in the pattern, provided there have been that many previous capturing left parentheses."

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