0.2.0 • Published 8 years ago

char-replace v0.2.0

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

CharReplace module

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

API Documentation

Modules

Classes

charReplace

Kind: global class

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)
0.2.0

8 years ago

0.1.0

8 years ago