GlobFilter

Filter strings by first cutting out a region (include) and then selectively remove (exclude) from that region.

I often use this in my programs to allow a user to specify what files to process and the have some control over what to exclude.

Constructors

this
this(string[] include, string[] exclude)

The regular expressions are set to ignoring the case.

Members

Functions

match
bool match(string s, void delegate(string s, string[] filters) @(safe) logFailed)

Variables

exclude
string[] exclude;
Undocumented in source.
include
string[] include;
Undocumented in source.

Examples

Example:

import std.algorithm : filter;
import std.array : array;

auto r = GlobFilter(["foo*"], ["*bar*", "*batman"]);

assert(["foo", "foobar", "foo smurf batman", "batman", "fo",
        "foo mother"].filter!(a => r.match(a)).array == [
        "foo", "foo mother"
        ]);

Meta