This is a small module that does one thing which is replacing a character in a string.
Kind: global class
charReplace module
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','%',';')
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%','%',';')
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)