Fast string replacement
I have the following sample string:
(My actual strings are much longer than this)
s = "You must eat lots of fruits and vegetables every day
in the daytime hours."
I'm looking for a fast way to replace an entire set of words
in the above string as follows:
"must" - "should"
"fruits" - "eggs"
"vegetables" - "bacon"
"day" - "morning"
The final output should be:
"You should eat lots of eggs and bacon every morning
in the daytime hours."
The string replacements must occur on word boundaries
only. So, if "daytime" occurs in the string, then I do not
want to change that to "morningtime".
The faster the solution, the better. Would a regular
expression approach be faster than using a "for-each"
construct with a bunch of boolean logic and Instr() calls?
|