This entry was posted on Wednesday, November 21st, 2007 at 1:07 pm and is filed under IBM Lotus Notes, LotusScript. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
BizzyBee’s BizzyThoughts
Think Outside The Hive - About Notes and Web
FindAndReplace in LotusScript
There’s @ReplaceSubstring in formula, there’s the FindAndReplace method for a NotesRichtextRange in LotusScript, but it doesn’t exist for a ordinary string.
This is the shortest (one line of code) function I can think of to build my own FindAndReplace. It can be a very old tip, or a very obvious one, I don’t know.
It’s really easy: I just split a string with the text-to-find as “splitter”, and join it back with the replacement text.
Function FindAndReplace(SourceText As String,FindText As String,ReplaceText As String) As String FindAndReplace=Join(Split(SourceText,FindText),ReplaceText) End Function
Gimme some feedback! Do you know this for years? Do you have another way of achieving this? Are there downsides?
Articles
Da Honey Pot
About me


(4 votes, average: 3.25 out of 5)
December 24th, 2007 at 1:10 pm
Martin,
Why don’t you just use the ‘built-in’ Replace function ?
December 25th, 2007 at 12:55 pm
Hi Theo,
According to Designer Help, this function is meant to replace elements in arrays. Or maybe you know how to use it in a different way?
January 15th, 2008 at 9:59 am
Hi Martin,
The built-in Replace function works just fine on plain strings.
Example:
strMyString = Replace(strMyString, “”, “Ken”)
January 15th, 2008 at 9:44 pm
Okay… Thanks for learning me this!