Find and replace text in a string.

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

   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.


myString="Hello John"
WScript.Echo myString

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

Related VBScript commands

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

Copyright © 1999-2024
Some rights reserved