| 4 September 2002 |
ReplaceStr() |
| Author | Lee Wilmott |
| Action | Given a string, this function replaces either the first occurrence or all occurrences of second supplied string. |
| Syntax | ReplaceStr ("text", "find", "replace" [,"replaceall"]) |
| Parameters | text (Required / String) The string that is to be searched. find (Required / String) The string that should be replaced. replace (Required / String) The string that should replace the specified "find" text. replaceall (Optional / Numeric) Specifies whether the first or all occurences of the given string should be replaced (-1 = all occurences are replaced, otherwise = first occurence replaced). |
| Remarks | I know that similar functions exist in the Function Library (Replace and StringReplace). However, they didn't seem to be able to perform the functions that I required. I have intentionally made the "replaceall" parameter require a "-1" value to replace all occurences. Perhaps this function would then be a little more useful as it could be modified to accept a positive number which could indicate how many occurences to replace. NOTE: If the text to be searched is an empty string ("") and the string that should be replaced is also an empty string ("") then this function always returns an empty string. Although I don't think this is how it should work, this is how the Replace() function in VisualBASIC operates. |
| Returns | A string with substrings replaced with a given string. |
| Dependencies | None. |
| Examples | |
| Source | |