在双引号内搜索并替换字符串

问题描述:

如何使用vbscript在文件中的双引号中搜索和替换字符串?在双引号内搜索并替换字符串

例如:“thisisstring”是否可以搜索thisisstring来替换“wearestrings”?

+1

SO是不是我们阅读[文档]的地方(https://msdn.microsoft.com/en-us/library/238kz954)到一个小例子您。 –

+0

非常抱歉,我认为我的担心被误解,我担心我们如何搜索和替换任何特殊字符所包含的任何字词(用户不知道所包含的字词),在这里我给出了特殊字符“”。 – InConfusionwidcode

+0

你想替换任意的单词或特定的单词吗?在任何一组特殊字符之间或双引号之间。请具体(例子会有所帮助)。同时显示您目前拥有的代码。就目前而言,你的问题既不明确,也过于宽泛。 –

此使用the function Replace()

Option Explicit 
Dim Message,MyString,ReplaceString,NewMessageString 
Message = "Hello ""thisisstring"" Example" 
MyString = DblQuote("thisisstring") 
ReplaceString = DblQuote("wearestrings") 
NewMessageString = Replace(Message,MyString,ReplaceString,1) 
wscript.echo Message & VbcrLF & NewMessageString 
'***************************************************** 
Function DblQuote(Str) 
    DblQuote = Chr(34) & Str & Chr(34) 
End Function 
'*****************************************************