[Issue 1772] New: regexp.split behaves incorrectly for paths with captures

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 7 21:03:32 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1772

           Summary: regexp.split behaves incorrectly for paths with captures
           Product: D
           Version: 1.025
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: wbaxter at gmail.com


I want to split columns out of a row of numbers.  They may be separated by
comas or by just white space.  So I tried this:

The splitter regexp
    auto re_splitter = new RegExp(r"(\s+|\s*,\s*)");
    char[][] numbers = re_splitter.split(line);

if input is a line like:
410.90711,352.879

The output from that is the array
[410.90711,,,352.879]

After a bit of debugging, it turns out the problem is the grouping in the
regexp.
Removing the parens fixes the problem in this case, but there are cases where
you need parens for grouping and not for the capturing side effect.  So I think
this is a bug.  Only match 0 should be considered significant for splitting,
not the submatches.


-- 



More information about the Digitalmars-d-bugs mailing list