str-match
v2.1.7
Published
String matcher that output the input string replacing the match.
Downloads
25
Maintainers
Readme
str-match
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.