ReFilter

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.

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

Variables

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

Examples

Example:

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

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