Socket
Socket
Sign inDemoInstall

char-replace

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

char-replace

replace character in a given string


Version published
Maintainers
1
Created
Source

CharReplace module

This is a small module that does one thing which is replacing a character in a string.

API Documentation

Modules

charReplace

Classes

charReplace

charReplace

Kind: global class

  • charReplace
    • new charReplace()
    • .replaceOne(source, charToFind, charToReplaceBy)String
    • .replaceAll(source, charToFind:, charToReplaceBy:)string
    • .replaceByCounter(source, charToFind:, charToReplaceBy:, numberOfOccurrences)string

new charReplace()

charReplace module

charReplace.replaceOne(source, charToFind, charToReplaceBy) ⇒ String

Replace one occurrence of charToFind with charToReplaceBy in source

Kind: instance method of charReplace Returns: String - source after character been replaced

ParamTypeDescription
sourceStringthe string we want to manipulate
charToFindStringthe one character that will be searched in source
charToReplaceByStringthe character that will replace charToFind

Example

// returns test;test
charReplace.replaceOne('test%test','%',';')

charReplace.replaceAll(source, charToFind:, charToReplaceBy:) ⇒ string

Replace ALL occurrence of charToFind with charToReplaceBy in source

Kind: instance method of charReplace Returns: string - source after character been replaced

ParamTypeDescription
sourceStringthe string we want to manipulate
charToFind:stringthe one character that will be searched in source
charToReplaceBy:stringthe character that will replace charToFind

Example

// returns ;test;test;
charReplace.replaceAll('%test%test%','%',';')

charReplace.replaceByCounter(source, charToFind:, charToReplaceBy:, numberOfOccurrences) ⇒ string

Replace number of occurrence of charToFind with charToReplaceBy in source based on numberOfOccurrences

Kind: instance method of charReplace Returns: string - source after character been replaced

ParamTypeDescription
sourceStringthe string we want to manipulate
charToFind:stringthe one character that will be searched in source
charToReplaceBy:stringthe character that will replace charToFind
numberOfOccurrencesnumberthe number of occurrences you want to replace

Example

// returns ;test;test%
charReplace.replaceByCounter('%test%test%','%',';',2)

Keywords

FAQs

Package last updated on 07 Mar 2016

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