Bug 5857 – std.regex (...){n,m} is bogus when (...) contains repetitions

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-04-18T13:42:00Z
Last change time
2011-06-06T08:35:03Z
Assigned to
nobody
Creator
dmitry.olsh

Comments

Comment #0 by dmitry.olsh — 2011-04-18T13:42:29Z
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'.
Comment #1 by dmitry.olsh — 2011-06-06T08:35:03Z