2013-03-28 3 views
0

HTML 페이지의 텍스트를 검색하고 바꿀 수있는 vb 스크립트가 있습니다. 은 다음과 같다 : -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 Under 조사'가 표시되면 'down'으로 지정하십시오. 누군가가 '오'기능을 '확인'을 '아래'로 대체하거나 '조사 중'을 '아래'로 바꿀 수있는 기능을 어떻게 넣을 수 있는지 알고 있습니까?

내가 원하는 단어를 말하기가 어렵다. 내가 분명하지 않으면 미안하다. 어떤 질문이라도 환영합니다!

많은 감사!

답변

0

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 
+0

니스 하나 안스, 감사합니다. –