Table of Contents
iReplace
Convenient case insensitive string replacement with optional multiple replacement.
Parameters
haystack
string The string to search within.needle
string The string to search for within the haystack, case insensitive.replacement
string The string to replace the needle with. Regexp replacement strings can be used here.multi
boolean Whether to enable multiple replacemement. Default is to only replace the first occurence. (optional, defaultfalse
)
Examples
const iReplace = const haystack = '<HEAD></HEAD>'const needle = '</head'const replacement = '<style>body { margin: 0}</style>$1'console// outputs <HEAD><style>body { margin: 0}</style></HEAD>
Returns string the haystack after needle replacement