[Issue 5857] New: std.regex (...){n, m} is bogus when (...) contains repetitions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Apr 18 13:46:02 PDT 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 at puremagic.com
        ReportedBy: dmitry.olsh at gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh at 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: -------


More information about the Digitalmars-d-bugs mailing list