Replace a set of strings contained in an array with a corresponding string in the 'replacement' array, or use a single string used as 'replacement'. If arrays are used they MUST be the same length. Using the 'g' flag replaces all occurences of search, 'i'
Homepage Repository npm Download
npm install areplace@1.0.5
Node.js replace version using an array of strings as "find" and either an array of strings or a single string as "replace". If "find" and "replace" arrays are used then they have to be the same length. Using the flag "g" causes all occurrences of search to be replaced with the corresponding "replace" if arrays are used. Using the "i" flag makes the replace case insensitive.
Examples: const str = 'fuzzy blobs are found ALL over the universe.'; let sarr = ['are', 'all', 'universe']; let rarr = ['will 'be', 'in', 'planet']; console.log(str.areplace(sarr, rarr, 'g')); or case insensitive: console.log(str.areplace(sarr, rarr, 'gi'));