[Issue 9211] regex lookahead, (?=(\d\d\d)+\b) failed
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Dec 27 08:15:23 PST 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9211
Dmitry Olshansky <dmitry.olsh at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |dmitry.olsh at gmail.com
--- Comment #1 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2012-12-27 08:15:19 PST ---
Now that was neasty.
The bug lurked in a branch-test code of *-repetition. It was too optimistic
optimization and it was curbed down back then. Looks like one case slipped
through.
The reduced test case doesn't require lookahead at all:
version A1 prints [["123", "12", "3"]] (!!)
version A2 prints [["1234", "3", "4"]]
The bug is triggered in a specific scenarios but is quite deadly.
import std.regex, std.stdio;
int main(string[] args)
{
version(A1)
{
auto rx_1 = regex(r"^(\w)*(\d)");
auto m = match("1234", rx_1);
auto captures = m.front;
writefln("%s", captures);
}
version(A2)
{
auto rx_2 = regex(r"^([0-9])*(\d)");
auto m2 = match("1234", rx_2);
auto captures2 = m2.front;
writefln("%s", captures2);
}
return 0;
}
--
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