1.1.0 • Published 8 years ago
i-replace v1.1.0
Table of Contents
iReplace
Convenient case insensitive string replacement with optional multiple replacement.
Parameters
haystackstring The string to search within.needlestring The string to search for within the haystack, case insensitive.replacementstring The string to replace the needle with. Regexp replacement strings can be used here.multiboolean Whether to enable multiple replacemement. Default is to only replace the first occurence. (optional, defaultfalse)
Examples
const iReplace = require('i-replace')
const haystack = '<HEAD></HEAD>'
const needle = '</head'
const replacement = '<style>body { margin: 0}</style>$1'
console.log(iReplace(haystack, needle, replacement))
// outputs <HEAD><style>body { margin: 0}</style></HEAD>Returns string the haystack after needle replacement