Visual Basic或运算符
问题描述:
我有一些vb脚本可以搜索并替换html页面中的文本。 它看起来像这样: -Visual Basic或运算符
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "<span>OK</span><!--test-->" , "<span class=""down"">Down</span><!--test-->")
Set objFile = objFSO.OpenTextFile("", ForWriting)
objFile.WriteLine strNewText
objFile.Close
这个伟大的工程,如果我有文字只是一个字符串替换。 但是,我需要脚本来更改以下内容。 此: -
<span class=""under-investigation"">Under investigation</span><!--test-->
这样: -
<span class=""down"">Down</span><!--test-->
它应该是 '是' '或' 虽然。如果字符串显示'OK',则将其设为'down',如果字符串显示'Under Investigation',则将其设置为'down'。 有谁知道我怎么能把一个或一个函数放在那里说'取代''取代'或'取代''取代''调查'?
很难说出我想要的,抱歉,如果我不清楚。任何问题欢迎!
非常感谢!
答
只需添加第二个Replace
指令?
strNewText = Replace(strText, "<span>OK</span><!--test-->" , "<span class=""down"">Down</span><!--test-->")
strNewText = Replace(strNewText, "<span class=""under-investigation"">Under investigation</span><!--test-->" , "<span class=""down"">Down</span><!--test-->")
或者做这样的事情:
If InStr(strText, "<span>OK</span><!--test-->") > 0 Then
strNewText = Replace(strText, "<span>OK</span><!--test-->" , "<span class=""down"">Down</span><!--test-->")
Else
strNewText = Replace(strText, "<span class=""under-investigation"">Under investigation</span><!--test-->" , "<span class=""down"">Down</span><!--test-->")
End If
尼斯一个安斯加尔,谢谢。 – 2013-03-28 12:01:03