Thread overview
[Issue 5857] New: std.regex (...){n,m} is bogus when (...) contains repetitions
Apr 18, 2011
Dmitry Olshansky
Apr 19, 2011
Dmitry Olshansky
Jun 06, 2011
Dmitry Olshansky
April 18, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5857

           Summary: std.regex (...){n,m} is bogus when (...) contains
                    repetitions
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: dmitry.olsh@gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2011-04-18 13:42:29 PDT ---
Uncovered while fixing greediness issues in current implementation.

For instance:

import std.regex;
void main(){
    auto c = match("axxxzayyyyyzd",regex("(a.*z){2}d")).captures;
    assert(c[0] == "axxxzayyyyyzd"); //asserts, there is no match ?!
    assert(c[1] == "ayyyyyz");
}

While it's certainly matches, try http://www.regextester.com/
(both PHP preg & JavaScript one).
The reason is that .* on the first iteration jumps out of ...{2} "scope",
skipping next  iteration of '(a.*z)' before trying 'd'.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
April 19, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5857


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|critical                    |normal


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5857


Dmitry Olshansky <dmitry.olsh@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


--- Comment #1 from Dmitry Olshansky <dmitry.olsh@gmail.com> 2011-06-06 08:35:03 PDT ---
Fixed in 2.053 https://github.com/D-Programming-Language/phobos/commit/c3ec6b2387d50ceab14cb648de6abb96b2b11f33

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------