🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

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

0.2.0
latest
Source
npm
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

character

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