D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2655 - Allow alternation patterns in std.path.fnmatch
Summary: Allow alternation patterns in std.path.fnmatch
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D1 (retired)
Hardware: x86 Windows
: P2 enhancement
Assignee: Andrei Alexandrescu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-11 21:58 UTC by Bill Baxter
Modified: 2014-03-01 00:36 UTC (History)
1 user (show)

See Also:


Attachments
fnmatch function enhanced with {,} patterns (6.66 KB, text/x-dsrc)
2009-02-11 22:00 UTC, Bill Baxter
Details

Note You need to log in before you can comment on or make changes to this issue.
Description Bill Baxter 2009-02-11 21:58:51 UTC
It would be nice if fnmatch also supported the standard alternaltion syntax for wildcards, where "abc.{def,ghi}.jkl" matches either abc.def.jkl or "abc.gji.jkl".

Attached is a modified version of the function that does that.

Like the current implementation, the additions lack an escape syntax.  So it's not possible to match filename with a literal ',' or '{'.  (Just like the current function is unable to match a literal '[', '*' or '?' in a filename)
Comment 1 Bill Baxter 2009-02-11 22:00:09 UTC
Created attachment 289 [details]
fnmatch function enhanced with {,} patterns
Comment 2 Andrei Alexandrescu 2010-09-26 13:03:09 UTC
Included with credit the proposed function and unittest, with minor changes. Thanks!

http://www.dsource.org/projects/phobos/changeset/2058