Replace

Find and replace text in a string.

Syntax
       Replace(String, StringToFind, ReplaceString
          [,Start [,Count [, Compare]]])

Key
   String         The initial string of Text
   StringToFind   The text we want to find in String
   ReplaceString  The string that will replace StringToFind if a match is found
   Start          Character position in string at which to start the search
   Count          The number of replacements to perform
   Compare        Either vbBinaryCompare or VBTextCompare

If ReplaceString ="" then the StringToFind will be deleted from String.

Example

myString="Hello John"
myString=Replace(myString,"John","world")
WScript.Echo myString

“Reputations are made by searching for things that can't be done and doing them” ~ Frank Tyger

Related:

replace.vbs - Script to search and replace text
InStr - Find one string within another
RegExp - Regular expression search object
StrComp - Compare two strings
Equivalent Powershell command: $result = "Hello Cleveland" -replace("Cleveland","world")


© Copyright SS64.com 1999-2013
Some rights reserved