我有一个需要字符串比较的 vbscript 函数,其中一个/两个字符串可能包含通配符。不幸的是,strcomp("string1","string.*")=0
它对我不起作用,因为它正在进行比较并将.*
正则表达式通配符视为文字而不是通配符。
如何比较两个字符串,其中一个和/或两个都包含通配符?
功能:
Function webtableCheck(pageName, tableProperty, rowNum, colNum, checkValue)
Dim x, y, oD, oC
x = split(tableProperty,":=")
If checkValue <> "" Then
Set oD = description.Create
oD("micclass").value = "WebTable"
oD(x(0)).value = x(1)
Set oC = pageName.childobjects(oD)
y = oC(0).getcelldata(rowNum, colNum)
msgbox(y)
If y=checkValue Then
reporter.ReportEvent micPass, "WebTable Checkpoint", "The webtable checkpoint object """ & checkValue & """ was found."
Elseif **strcomp(y,checkValue,1)** = 0 Then
reporter.ReportEvent micPass, "WebTable Checkpoint", "The webtable checkpoint object """ & checkValue & """ was found, however the casing does not match."
Elseif strcomp(trim(y),trim(checkValue)) = 0 Then
reporter.ReportEvent micPass, "WebTable Checkpoint", "The webtable checkpoint object """ & checkValue & """ was found, however leading/lagging spaces not included in datatable and/or webtable cell was found."
Elseif instr(1,y,checkValue,1) Then
reporter.ReportEvent micPass, "WebTable Checkpoint", "The webtable checkpoint object """ & checkValue & """ was found., however a line break or other hidden character was found in the webtable."
Else
reporter.ReportEvent micFail, "WebTable Checkpoint", "The webtable checkpoint object """ & checkValue & """ was not found."
End If
End If
End Function