[Update: Read the comments for a better solution with short strings (unverified)!]
Had this problem removing single characters in a string. I don’t like the idea to use strRight() and strLeft() since they can only handle a single entry of the search string.
There are a lot of different solution for this. I have also made my own lotusscript function for @replaceSubString, as every one else. All to complex since Release 6.
Some split and join will do the trick. This is my one liner:
resultStr = join( split( sourceStr, fromStr ), toStr )
The replace is case sensitive.
Example replacing word:
Button code:
Dim ui As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set uidoc = ui.CurrentDocument
Set doc = uidoc.Document
doc.result = Join(Split(doc.text(0),doc.Replace(0)),doc.replacewith(0))
Example removing character:
Or make a function out of it to make it more readable:
Function replaceSubString(sourceStr As String, fromStr As String, toString As String) As String
replaceSubString = Join(Split(sourceStr,fromStr),toString)
End Function