Skip to content

tommedema/i-replace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Convenient case insensitive string replace for node.

Resources

License

Stars

Watchers

Forks

Packages

No packages published