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 = ; <br>var multiReplace = replacermultiReplace; <br><br>var origStr = '<p>Anyone here wants to code?</p>';var searchStrArr = '<p>' '</p>';var outStr = //replace <p> & </p> with empty character;console; //Anyone here wants to code?
Test
npm test
Note
This is still a WIP, will use ES6 in the future.