[Issue 4627] New: Ideas for std.regex.match usage syntax

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Aug 11 19:21:20 PDT 2010


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

           Summary: Ideas for std.regex.match usage syntax
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-08-11 19:21:18 PDT ---
Ideas for possible changes in std.regex.match() user interface, mostly to
shorten it, but also to make it simpler to use.

This is what you currently ned to use to iterate on matches:

stringtext = "...";
foreach (m; match(text, regex(r"\d")).captures) { ... }


The regex() there is useful because you can add attributes like "g" as second
argument, but often I don't need attributes, while often I may appreciate a
shorter syntax (even if I don't need a built-in regex syntax as in Ruby and
Perl).

So match() can accept as second argument both an engine (regex) or a string,
when attributes are not necessary:

foreach (m; match(text, r"\d").captures) { ... }


Another possible idea to shorten the syntax is to make match() iterable (I
don't know if this is possible or if it is a good idea), this also makes it
simpler to use (no need to know about 'captures'):

foreach (m; match(text, r"\d")) { ... }

-- 
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