Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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.

About

Simple string matching utility.

Resources

License

Packages

No packages published
You can’t perform that action at this time.