Tuesday, October 27, 2009

ReplaceAll function in lotus script

Code snippet to stimulate replaceAll function in lotus script

Function StringReplaceAll(Byval strArg As String, Byval strSrc As String,Byval strDst As String) As String

Dim iPos As Integer
iPos = Instr(strArg, strSrc)

While iPos > 0
strArg = Left$(strArg, iPos - 1) + strDst + Mid$(strArg, iPos + Len(strSrc))
iPos = Instr(iPos + Len(strDst), strArg, strSrc)

StringReplaceAll= strArg

End Function

The function call
StringReplaceAll("hello","l", "g") will give the result as 'heggo'

1 comment:

  1. Hi,

    since IBM released Join & Split i always use something like this.


    Best wishes