1.1.0 • Published 6 years ago

i-replace v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

JavaScript Style Guide

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, default false)

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