OpenNTF.org - ReplaceSubString (Unlimited No
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
ReplaceSubString (Unlimited Now ;) 
Rating:
Rating: 2 , Number of votes: 1 
Contributor:
Dmitry Akulov 
Category:
Lotusscript 
Type:
String Functions 
Notes Version:
R5.x, R6.x 
Last Modified:
30 Nov 2004 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
Private Function ReplaceSubstring(Byval source As String, Byval find As String, Byval target As String) As String

Dim i As Integer
i=Instr(source,find)
If i>0 And Len(find)>0 Then
ReplaceSubstring=Left(source,i-1) + target + ReplaceSubstring(Mid(source,i+Len(find)),find,target)
Else
ReplaceSubstring=source
End If
End Function

Usage / Example
 Comments
Posted by John Marshall on 11/20/2003 04:11:54 AMStack overflow
This function wil run out of stack space
e.g.
replacesubstring("ANDAND ", "AND", "AND ") = Out of stack space
regards john marshall
Posted by Dmitry Akulov on 11/20/2003 02:29:50 PMRe:Stack overflow - fixed
Oops, this was tipical recursive algo error
Posted by Pierre Koerber on 11/30/2004 08:37:55 AMRe: ReplaceSubString (Unlimited)
Doesn't work with :
Original String : hello
toReplace : l
targetValue : ll
Result : hello
Works with formula....
Posted by Dmitry Akulov on 11/30/2004 10:10:32 AMfixed, thanks
oops, one more
Posted by John Smart on 02/07/2005 03:47:30 PMalternative submission
http://www.openntf.org/Projects/codebin/codebin.nsf/CodeByDate/49F197271969496088256C550022C055
Posted by Dmitry Akulov on 02/08/2005 03:55:01 AMaltsubmission slightly faster, but this function work well (-)
no comment
 Add your comment!