http://d.puremagic.com/issues/show_bug.cgi?id=7962
Summary: std.regex: Captures.length() returns incorrect value Product: D Version: D2 Platform: x86_64 OS/Version: Linux Status: NEW Severity: normal Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: marku...@gmail.com --- Comment #0 from Markus Dittrich <marku...@gmail.com> 2012-04-21 13:14:03 PDT --- It seems that Captures.length() from std.regex returns bogus lengths for empty captures (I might be using it improperly). Here's a simple example, the second match object claims length 2 while being empty. sh-4.2$ uname Linux sh-4.2$ dmd | grep "DMD" DMD64 D Compiler v2.059 sh-4.2$ cat test.d import std.regex; import std.stdio; int main() { auto r = regex(r"(@\w+)", "g"); writeln("match first string -- looks ok"); string text1 = "@This is a test"; auto m1 = match(text1, r); auto myCapts1 = m1.captures; writeln("content: ", myCapts1); writeln("is empty? ", myCapts1.empty()); writeln("length: ", myCapts1.length()); writeln(""); writeln("match second string -- length seems wrong"); string text2 = "(his) is a test"; auto m2 = match(text2, r); auto myCapts2 = m2.captures; writeln("content: ", myCapts2); writeln("is empty? ", myCapts2.empty()); writeln("length : ", myCapts2.length()); return 0; } sh-4.2$ dmd test.d sh-4.2$ ./test match first string -- looks ok content: ["@This", "@This"] is empty? false length: 2 match second string -- length seems wrong content: [] is empty? true length : 2 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------