I need to find a replace function for LotusScript that will replace all double quotes (") in a string with backslash quote (") and all backslashes with a double backslash (\).
I have not had any luck with Evaluate and @ReplaceSubstring. Hopefully someone can help.
As an example, I want to this input string:
Amy replied, “The correct path is: c:\lotus\notes\data”.
… to be ouput as …
Amy replied, "The correct path is: c:\lotus\notes\data".
Subject: Need LotusScript code to escape backslashes and quotes
I pinched this from this forum a few years ago …
Function fnReplaceSubString(_
Byval st As String, _
Byval f As String, _
Byval t As String) As String
'/**
'* Function replaceSubString
'* The following function will search the
'* passed string “st” for the string “f”. If
'* found all instances will be replaced with
'* the string “t”.
'*
'* @param st the string to be parsed
'* @param f the string that we are looking for
'* @param t the string that we would like “f”
'* to be changed to
'*
'* @return a new string with all instances “f”
'* replaced by “t”
'*
'*/
Dim returnValue As String
Dim temp As String
temp = st
Dim i As Integer
i = Instr(temp, f)
While (i > 0)
returnValue = _
returnValue + _
Left(temp, i -1) + t
temp = Mid(temp, i + Len(f))
i = Instr(temp, f)
Wend
returnValue = returnValue + temp
fnReplaceSubString = returnValue
Subject: RE: Need LotusScript code to escape backslashes and quotes
Thank you both very much!
I ended up trying the Replace function first, and it worked well. For some reason, I was too confused last week by the replace example provided in Designer help to just try simple strings.