Web Design, Programming, Tutorials
String Replace Function For Lotus Script
Here is a handy function that I sometimes use in my Lotus Script programs.
'=============================================================================== ' +----------------------------------------------------------------------------+ ' | Function: strreplace ' +----------------------------------------------------------------------------+ ' | Accepts: src, the value to search for to replace. ' | dest, the value to replace with. ' | arg, the string to search within. ' +----------------------------------------------------------------------------+ ' | Description: ' | Replaces all occurances of src with dest in the string arg. ' +----------------------------------------------------------------------------+ '=============================================================================== Public Function strreplace(Byval src As String, Byval dest As String, Byval arg As String) As String 'Declare variables Dim pos As Integer 'Initialize pos = Instr(arg, src) 'Loop through the string While (pos > 0) arg = Left(arg, pos - 1) + dest + Mid(arg, pos + Len(src)) pos = Instr(pos + Len(dest), arg, src) Wend 'Return the replaced string strreplace = arg End Function
Here is an example of how to use the function:
newString = strreplace("WORLD", "World", "Hello WORLD!")
The newString variable would contain “Hello World!”
about 11 months ago
Thanks for this nice piece of code. It helped me a lot with a Domino 5 server.
about 7 months ago
Great! I was saved by this script. Thanks!
about 2 months ago
Nice Great one