match-str

0.2.1 • Public • Published

match-str 🧵

npm version Travis Status

Small, no dependency tool to match strings against regular expressions.

Usage

$ 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.

Notes

  • Provides no stdout, just exit process with 0 for match or 1 for no match.
  • Matching logic is: 0. Split lines at newline. Then, for each line:
    1. If -i flags are provided, lines are filtered to at least one match.
    2. If -e flags are provided, lines are excluded.
    3. If any lines remain, process exits 0 else 1.
  • Can have multiple -i and -e options.

Readme

Keywords

none

Package Sidebar

Install

npm i match-str

Weekly Downloads

1

Version

0.2.1

License

MIT

Unpacked Size

7.28 kB

Total Files

6

Last publish

Collaborators

  • ryan.roemer