multi-replacer

1.0.1 • Public • Published

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.

Package Sidebar

Install

npm i multi-replacer

Weekly Downloads

2

Version

1.0.1

License

ISC

Last publish

Collaborators

  • cyval