sim-replace
v1.0.1
Published
A small utility to execute multiple replaces simultaneously
Maintainers
Readme
sim-replace
A small utility to execute multiple replaces simultaneously
About
sim-replace, or Simultaneous Replace, is a small utilty that will execute mutliple regex replaces simultaneously.
Installation
Install via Yarn (recommended):
yarn add sim-replace -DInstall via NPM:
npm install sim-replace --save-devUsage
Note that we're using ES6 import statements here. Usage with require works just as well.
import simReplace from 'sim-replace'
let text = 'There was a cow and a cat'
let result = simReplace(text, [
[/cow/g, 'cat'],
[/cat/g, 'cow']
])
result === 'There was a cat and a cow' // trueIt also supports capturing group placeholders
import simReplace from 'sim-replace'
let text = 'This is my sister'
let result = simReplace(text, [
[/(my sister)/g, 'Fanny, $1']
])
result === 'This is Fanny, my sister' // trueContributing
- Fork it (https://github.com/scriptcoded/sim-replace/fork)
- Create your feature branch (
git checkout -b feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request
Additional information
Malcolm Nihlén - [email protected]
Distributed under the MIT licence. See LICENCE for more information.
https://github.com/scriptcoded
