@ReplaceSubString in LotusScript (v2)


LotusScript


Function ReplaceSubstring(inputStr As String, fromStr As String, toStr As String) As String	
	
	Dim newStr As String
	newStr = inputStr
	
	If InStr(1,inputStr,fromStr,5)=0 Then
		'key is not in the value
		ReplaceSubstring = Trim(inputStr)
		Exit Function	
	End If
	
	While Instr(newStr, fromStr) > 0
		pos = Instr(newStr, fromStr)
		newStr = Left$(newStr, pos - 1) + toStr + Right$(newStr, Len(newStr) - (pos + Len(fromStr) - 1))
	Wend
	
	ReplaceSubstring = newStr
	
End Function

Written by Frank Joseph Brefere III

Posted by fbrefere001 on Saturday August 9, 2008