frep
Version:
Find and replace utility for node.js. Transform strings by running multiple RegExp or string find-and-replace patterns on a string in sequence, reducing the final string to the accumulated result of each transformation. Patterns can be strings (or arrays
51 lines (39 loc) • 718 B
Markdown
# {%= name %} {%= badge("fury") %}
> {%= description %}
## Quickstart
{%= include("install") %}
Usage:
```js
var replace = require('frep');
// Patterns can be strings, regex or arrays.
// Replacements can be strings or functions.
var replacements = [
{
pattern: 'a',
replacement: 'x'
},
{
pattern: /b/,
replacement: 'y'
},
{
pattern: /c[\S]+/,
replacement: function(match) {
return match.toUpperCase();
}
}
];
console.log(replace.strWithArr('abcdefg', replacements));
//=> 'xyCDEFG'
```
## API
{%= docs("api") %}
## Usage example
{%= docs("example") %}
## Author
{%= contrib("jon") %}
## License
{%= copyright() %}
{%= license() %}
***
{%= include("footer") %}