"tonycd" <tonycd@xxxxxx> wrote in message
news:74DABA76-6B73-4153-9926-2726ABF13D41@xxxxxx
Quote:
> Hi
>
> I just copy the script from Microsoft web site that for replace the text.
> But how can i enhance the script for multi - text replacement. Thanks
> i try with this (i put the star in front of script) , but it doesn't work.
>
> regards
> Tony
>
> Const ForReading = 1
> Const ForWriting = 2
>
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objFile = objFSO.OpenTextFile("C:\Scripts\Text.txt", ForReading)
>
> strText = objFile.ReadAll
> objFile.Close
> strNewText = Replace(strText, "Jim ", "James ")
> ****strNewText = Replace(strText, "abc ", "apple ")
>
> Set objFile = objFSO.OpenTextFile("C:\Scripts\Text.txt", ForWriting)
> objFile.WriteLine strNewText
> objFile.Close
You probably already have file script56.chm on your computer. If not, go to
msdn.microsoft.com's download tab and search for and download it, and read
up on the replace function.
It says that there are potentially more parameters for the replace function:
Replace Function
See Also
Filter Function
Requirements
Version 2
Returns a string in which a specified substring has been replaced with
another substring a specified number of times.
Replace(expression, find, replacewith[, start[, count[, compare]]])
Arguments
expression
Required. String expression containing substring to replace.
find
Required. Substring being searched for.
replacewith
Required. Replacement substring.
start
Optional. Position within expression where substring search is to begin. If
omitted, 1 is assumed. Must be used in conjunction with count.
count
Optional. Number of substring substitutions to perform. If omitted, the
default value is -1, which means make all possible substitutions. Must be
used in conjunction with start.
compare
Optional. Numeric value indicating the kind of comparison to use when
evaluating substrings. See Settings section for values. If omitted, the
default value is 0, which means perform a binary comparison.
-Paul Randall