Given you want word boundaries only, your list of words should include
the character following the word...
Function ReplaceWords$(sText$, sWords$)
Dim sz$, vTmp, v1, n&
v1 = Split(sWords, ","): sz = sText
For n = LBound(v1) To UBound(v1)
vTmp = Split(v1(n), ":")
sz = Replace(sz, vTmp(0), vTmp(1))
Next 'n
ReplaceWords = sz
End Function
Sub Test_ReplaceWords()
Const sWords$ = "must :should ,fruits :eggs ,vegetables :bacon ,day
:morning "
Const sText$ = "You must eat lots of fruits and vegetables every day
in the daytime hours."
Debug.Print ReplaceWords(sText, sWords)
End Sub
--
Garry
Free usenet access at
http://www.eternal-september.org
Classic
VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.
vb.general.discussion