@ReplaceSubString in LotusScript (v1)


LotusScript


Function replaceSubString( st As String, f As String, 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

	replaceSubString = returnValue

End Function 

Written by Edwin Macaraeg

Posted by fbrefere001 on Tuesday July 26, 2005