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.
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
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")