Professional Web Applications Themes

#46184 [NEW]: a problem with internal vars - PHP Bugs

From: vasilkov80 at mail dot ru Operating system: linux mandriva 2007 PHP version: 5.2.6 PHP Bug Type: *Regular Expressions Bug description: a problem with internal vars 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 ) -- Edit bug ...

  1. #1

    Default #46184 [NEW]: a problem with internal vars

    From: vasilkov80 at mail dot ru
    Operating system: linux mandriva 2007
    PHP version: 5.2.6
    PHP Bug Type: *Regular Expressions
    Bug description: a problem with internal vars

    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
    )

    --
    Edit bug report at http://bugs.php.net/?id=46184&edit=1
    --
    Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46184&r=trysnapshot52
    Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46184&r=trysnapshot53
    Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46184&r=trysnapshot60
    Fixed in CVS: http://bugs.php.net/fix.php?id=46184&r=fixedcvs
    Fixed in release: http://bugs.php.net/fix.php?id=46184&r=alreadyfixed
    Need backtrace: http://bugs.php.net/fix.php?id=46184&r=needtrace
    Need Reproduce Script: http://bugs.php.net/fix.php?id=46184&r=needscript
    Try newer version: http://bugs.php.net/fix.php?id=46184&r=oldversion
    Not developer issue: http://bugs.php.net/fix.php?id=46184&r=support
    Expected behavior: http://bugs.php.net/fix.php?id=46184&r=notwrong
    Not enough info: http://bugs.php.net/fix.php?id=46184&r=notenoughinfo
    Submitted twice: http://bugs.php.net/fix.php?id=46184&r=submittedtwice
    register_globals: http://bugs.php.net/fix.php?id=46184&r=globals
    PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46184&r=php4
    Daylight Savings: http://bugs.php.net/fix.php?id=46184&r=dst
    IIS Stability: http://bugs.php.net/fix.php?id=46184&r=isapi
    Install GNU Sed: http://bugs.php.net/fix.php?id=46184&r=gnused
    Floating point limitations: http://bugs.php.net/fix.php?id=46184&r=float
    No Zend Extensions: http://bugs.php.net/fix.php?id=46184&r=nozend
    MySQL Configuration Error: http://bugs.php.net/fix.php?id=46184&r=mysqlcfg

    vasilkov80 Guest

  2. #2

    Default #46184 [Opn]: a problem with internal vars

    ID: 46184
    User updated by: vasilkov80 at mail dot ru
    Reported By: vasilkov80 at mail dot ru
    Status: Open
    Bug Type: *Regular Expressions
    Operating System: linux mandriva 2007
    PHP Version: 5.2.6
    New Comment:

    sorry, expected result:

    Array
    (
    [0] => "image.jpg"
    [1] => "
    [2] => image.jpg
    )


    Previous Comments:
    ------------------------------------------------------------------------

    [2008-09-26 15:38:24] 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
    )


    ------------------------------------------------------------------------


    --
    Edit this bug report at http://bugs.php.net/?id=46184&edit=1

    vasilkov80 Guest

  3. #3

    Default #46184 [Opn->Bgs]: a problem with internal vars

    ID: 46184
    Updated by: net
    Reported By: vasilkov80 at mail dot ru
    -Status: Open
    +Status: Bogus
    Bug Type: PCRE related
    Operating System: linux mandriva 2007
    PHP Version: 5.2.6
    New Comment:

    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."



    Previous Comments:
    ------------------------------------------------------------------------

    [2008-09-26 15:44:59] vasilkov80 at mail dot ru

    sorry, expected result:

    Array
    (
    [0] => "image.jpg"
    [1] => "
    [2] => image.jpg
    )

    ------------------------------------------------------------------------

    [2008-09-26 15:38:24] 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
    )


    ------------------------------------------------------------------------


    --
    Edit this bug report at http://bugs.php.net/?id=46184&edit=1

    nlopess@php.net Guest

Similar Threads

  1. Problem with exception class and instance vars
    By Bennett, Patrick in forum Ruby
    Replies: 2
    Last Post: November 13th, 07:27 PM
  2. Problem with Windows and internal modem!!!
    By Aadil in forum Linux Setup, Configuration & Administration
    Replies: 3
    Last Post: September 5th, 12:09 PM
  3. Foreach POST VARS problem
    By Kris Yates in forum PHP Development
    Replies: 3
    Last Post: August 15th, 09:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139