Method: Replace word
Function name: replaceword
Parameter list: (CHAR input, CHAR searchWord, CHAR replaceWord)
Return type: CHAR
What the method does: Copy the input source string to the target string, looking for the word contained in the search word and replace every occurrence of this string of characters in the input string with the set of characters contained in the replacement word.
If the replacement word is specified as a zero length string then this is the indication to strip the word out and throw it away as opposed to replacing it.
The second argument can contain one or more characters that represents the word to be searched for and replaced or removed by the third argument, which is the replacement word.
Any of the strings can be zero-length strings, but this fact has different meanings depending on which string has this attribute: if the source is a zero-length string and the search string is a zero length string but the replacement string is not a zero length string then the source string (the empty string) is replaced with the replacement string.
replaceword('I have nothing in my pocket.' ,'nothing', 'something');
returns
I have something in my pocket.
replaceword('barfoobardbar','bar', '');
returns
food
replaceword('', '', 'Something for nothing!');
returns
Something for nothing!