www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12227] New: Allow matching multiple patterns in one go with std.regex

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12227

           Summary: Allow matching multiple patterns in one go with
                    std.regex
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: dmitry.olsh gmail.com


--- Comment #0 from Dmitry Olshansky <dmitry.olsh gmail.com> 2014-02-22
13:38:38 PST ---
Synposis:

auto m = matchFirst("42 days", `[a-z]+`, `\d+`);
assert(m.index == 2); //2nd pattern match
assert(m.index != 0); //same as not empty

foreach(item; "42 days".matchAll(`[a-z]+`, `\d+`))
{
     switch(item.index){
     case 1: 
             assert(item[0] == "days");
             break;
     case 2:
             assert(item[1] == "42");
             break;
     default:
             assert(0);
     }
}

Rationale - as a more efficient common basis for pattern matching (e.g.
switch-case on with regex patterns as cases).

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2014
parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12227


Dmitry Olshansky <dmitry.olsh gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 22 2014