path matching problem
Joshua Niehus
jm.niehus at gmail.com
Tue Nov 27 15:56:02 PST 2012
On Tuesday, 27 November 2012 at 23:43:43 UTC, Charles Hixson
wrote:
> But why the chained filters, rather than using the option
> provided by dirEntries for one of them? Is it faster? Just
> the way you usually do things? (Which I accept as a legitimate
> answer. I can see that that approach would be more flexible.)
Ignorance...
Your right, I didn't realize that dirEntries had that filter
option, you should use that. I doubt the double .filter would
effect performance at all (might even slow it down for all i know
:)
//update:
import std.algorithm, std.array, std.regex;
import std.stdio, std.file;
void main()
{
string exts = "*.{txt,utf8,utf-8,TXT,UTF8,UTF-8}";
enum string exclude =
`r"/template/|biblio\.txt|categories\.txt|subjects\.txt|/toCDROM/"`;
dirEntries("/path", exts, SpanMode.depth)
.filter!(` std.regex.match(a.name,` ~ exclude ~ `).empty `)
.writeln();
}
More information about the Digitalmars-d-learn
mailing list