Replace Function |
%Replace[$](S$, Pat$, Rep$, [Index], [Count])%
Replaces Pat$ with Rep$ in S$.
Parameter |
Description |
This string value is searched. Replacements are made in the string returned by Replace. |
|
This string value is the pattern to look for. |
|
This string value is the replacement. |
|
This numeric value is the starting index in S$. Replace(S,Pat,Rep,N) is equivalent to Replace(Mid(S,N),Pat,Rep). If this is omitted use 1. |
|
This numeric value is the maximum number of replacements that will be done. If this is omitted use -1 (which means replace all occurrences). |
Sub Main
Debug.Print Replace$("abcabc","b","B") '"aBcaBc"
Debug.Print Replace$("abcabc","b","B",,1) '"aBcabc"
Debug.Print Replace$("abcabc","b","B",3) '"caBc"
Debug.Print Replace$("abcabc","b","B",9) '""
End Sub
InStr( ), InStrRev( ), Left$( ), Len( ), Mid$( ), Right$( ).