str-match

2.1.7 • Public • Published

str-match

Last version Build Status Coverage Status Dependency status Dev Dependencies Status NPM Status Donate

String matcher that output the input string replacing the match.

I created this module for be easy create a pipeline string processor, where the output of a pipe is the input of the next pipe.

Install

$ npm install str-match --save

Usage

const strmatch = require('str-match')({ replacement: 'gift' })
 
const str = "I'm selling my Macbook Pro"
const regex = /selling/i
const detection = strmatch(str, regex)
 
console.log(detection)
// {
//  test: true,
//  match: 'Macbook Pro',
//  input: 'I\'m selling my Macbook Pro',
//  output: 'I\'m gift my Macbook Pro'
//  }

API

.constructor([opts])

opts

opts.flags

Type: string
Default: ''

opts.replacement

Type: string
Default: ''

strmatch(str, regex)

str

Required
Type: string

regex

Required
Type: regexp

License

MIT © Kiko Beats.

Package Sidebar

Install

npm i str-match

Weekly Downloads

3

Version

2.1.7

License

MIT

Unpacked Size

8.57 kB

Total Files

5

Last publish

Collaborators

  • kikobeats