Small, no dependency tool to match strings against regular expressions.
$ match-str -h
Usage: match-str [options]
Options:
--str, -s String to match on [String]
--include, -i If provided, must match pattern [RegExp]
--exclude, -e If provided, cannot match pattern [RegExp]
--help, -h Show help [boolean]
--version, -v Show version number [boolean]
Examples:
match-str -s "$(printf 'one\ntwo')" Exits 0. Matches by default.
match-str -i "^tw.+" -s "$(printf 'one\ntwo')" Exits 0. Matches "two" at line start.
match-str -e "one" -s "$(printf 'one\ntwo')" Exits 0. Still matches "two".
match-str -e ".*" -s "$(printf 'one\ntwo')" Exits 1. Everything excluded.
match-str -i "^three" -s "$(printf 'one\ntwo')" Exits 1. No include match.
- Provides no stdout, just exit process with
0
for match or1
for no match. - Matching logic is:
0. Split lines at newline. Then, for each line:
- If
-i
flags are provided, lines are filtered to at least one match. - If
-e
flags are provided, lines are excluded. - If any lines remain, process exits
0
else1
.
- If
- Can have multiple
-i
and-e
options.