|
Previous Top Next |
Prototype: | (String pFind, String pReplace, String pSearchS, <*LONG pNewLen>),String |
pFind | The string to search for. |
pReplace | The string to replace with. |
pSearchS | The string to search and replace in. This can be a string literal or a string variable. |
pNewLen | Omittable parameter that receives the new length of the string |
Returns | The resulting string with the pFind string replaced with the pReplace string |
This method is identical to the SearchReplace method except FindReplace can take a literal string or variable as the string to search in and instead of returning the number of replacements performed, it returns the new string. This makes it a little bit more flexible to use since you don't need to declare a variable to execute the search and replace.
Note that this method will be slightly slower than SearchReplace because it has to count the number of times the pFind is found in pSearchS in order to allocate enough memory for it to start the search and replace process. A simple test with the example code from SearchReplace took 0.71 seconds to run 100,000 (one hundred thousand) iterations of SearchReplace but 1.45 seconds to run the same number of iterations using FindReplace on the same machine. However, for most practical application the difference is not noticable.
Example:
S String(255)
ITC ITCoreClass
Code
S = ITC.FindReplace('now','NOW','Check this out now') ! S is now: 'Check this out NOW'
See also: