Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

multi-replacer

Cyval16ISC1.0.1

Multi-string replacer helper for Javascript

string, replacer, javascript, string-helper

readme

multi-replacer

Simple Javascript String Replace Helper

Introduction

A simple helper created to allow replacing strings with multiple search values.

Usage

The multiReplace function accepts three arguments namely:

origStr - the raw string (e.g. <p>This is an awesome test case.</p>, 'Hello World')
searchStrArr - array of characters to be replaced. (e.g. [<p>, </p>])
rplcStr - the character/string replacement (e.g. '', 'A' or any other string)

Example

var replace = require('multi-replacer'); <br>
var multiReplace = replacer.multiReplace; <br><br>

var origStr = '<p>Anyone here wants to code?</p>';
var searchStrArr = ['<p>', '</p>'];

var outStr = multiReplace(origStr, searchStrArr, "") //replace <p> & </p> with empty character;

console.log(outStr); //Anyone here wants to code?

Test

npm test

Note

This is still a WIP, will use ES6 in the future.