1.0.3 • Published 5 years ago

@vipulc/line-match v1.0.3

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

line-match

npm (scoped) npm GitHub issues GitHub forks GitHub stars GitHub license

Returns lines matching a pattern in a string. Supports inverse operation as well, to exclude lines with matches.

Install

$ npm install @vipulc/line-match

Usage

multiLineString.lineMatch(pattern);

Example

require("@vipulc/line-match");

const str1 = `Brave New World
  Fear and Loathing in Las Vegas
  World War Z`;

// lines ending with 'World'
console.log(str1.lineMatch(/World$/));
//=> ['Brave New World']

const str2 = `Brave New World
  Fear and Loathing in Las Vegas
  World War Z`;

// exclude lines ending with 'World'
console.log(str2.lineMatch(/World$/, { inverse: true }));
//=> [ '  Fear and Loathing in Las Vegas', '  World War Z' ]

License

MIT License