ReFilter

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

It assumes that if include is empty everything should match.

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

--re-include and --re-exclude is a suggestion for parameters to use with getopt.

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 type) @(safe) logFailed)

Variables

excludeRe
Regex!char[] excludeRe;
Undocumented in source.
includeRe
Regex!char[] includeRe;
Undocumented in source.

Examples

Example:

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

Meta