0.2.0 • Published 8 years ago
char-replace v0.2.0
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
Param | Type | Description |
---|---|---|
source | String | the string we want to manipulate |
charToFind | String | the one character that will be searched in source |
charToReplaceBy | String | the 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
Param | Type | Description |
---|---|---|
source | String | the string we want to manipulate |
charToFind: | string | the one character that will be searched in source |
charToReplaceBy: | string | the 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
Param | Type | Description |
---|---|---|
source | String | the string we want to manipulate |
charToFind: | string | the one character that will be searched in source |
charToReplaceBy: | string | the character that will replace charToFind |
numberOfOccurrences | number | the number of occurrences you want to replace |
Example
// returns ;test;test%
charReplace.replaceByCounter('%test%test%','%',';',2)