Socket
Socket
Sign inDemoInstall

replace-string

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

replace-string

Replace all substring matches in a string


Version published
Weekly downloads
236K
increased by9.91%
Maintainers
1
Weekly downloads
 
Created

What is replace-string?

The replace-string npm package is a simple utility for replacing all occurrences of a substring within a string with a new substring. It is useful for string manipulation tasks where you need to perform replacements in a straightforward and efficient manner.

What are replace-string's main functionalities?

Basic Replacement

This feature allows you to replace all occurrences of a specified substring within a string with a new substring. In this example, 'World' is replaced with 'Universe'.

const replaceString = require('replace-string');
const result = replaceString('Hello World', 'World', 'Universe');
console.log(result); // 'Hello Universe'

Case Sensitive Replacement

The replacement is case-sensitive by default. In this example, 'world' is not replaced because it does not match the case of 'World'.

const replaceString = require('replace-string');
const result = replaceString('Hello World', 'world', 'Universe');
console.log(result); // 'Hello World'

Replacing Special Characters

This feature allows you to replace substrings that include special characters. In this example, '$World$' is replaced with 'Universe'.

const replaceString = require('replace-string');
const result = replaceString('Hello $World$', '$World$', 'Universe');
console.log(result); // 'Hello Universe'

Other packages similar to replace-string

Keywords

FAQs

Package last updated on 10 May 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc