[pcre-dev] [Bug 1303] New: Recursion and greedy matching

Kezdőlap
Üzenet törlése
Szerző: Jille Timmermans
Dátum:  
Címzett: pcre-dev
Tárgy: [pcre-dev] [Bug 1303] New: Recursion and greedy matching
------- You are receiving this mail because: -------
You are on the CC list for the bug.

http://bugs.exim.org/show_bug.cgi?id=1303
           Summary: Recursion and greedy matching
           Product: PCRE
           Version: 8.12
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
        AssignedTo: ph10@???
        ReportedBy: jille@???
                CC: pcre-dev@???



When I make the recursive-backreference (?R) optional (with ?) it doesn't match
the data to its full extent.

I've tested this with pcretest 7.7 and PHP 5.4.7 (uses pcre 8.12).

When I match this regex, I would expect the second } to be included in 0.

re> /{[A-Z]+(\|param:[^|}]*(?R)?[^|}]*)*}/
data> A{X|param:{Y}}B

0: {X|param:{Y}
1: |param:{Y

If I make de (?R) mandatory, it does work as expected:
re> /{[A-Z]+(\|param:[^|}]*(?R)[^|}]*)*}/
data> A{X|param:{Y}}B

0: {X|param:{Y}}
1: |param:{Y}

And I've found the following workaround to do what I want:
re> /{[A-Z]+(\|param:([^|}]*(?R)[^|}]*|[^|}]*))*}/
data> A{X|param:{Y}}B

0: {X|param:{Y}}
1: |param:{Y}
2: {Y}


--
Configure bugmail: http://bugs.exim.org/userprefs.cgi?tab=email