所以我目前遇到的问题是我想在电话号码上使用通配符,但似乎我不能在开关盒中使用任何通配符
CallID = 0049555
Select Case CallID
case "0049*"
wscript.echo "Case 1"
case 0049*
wscript.echo "Case 2"
case 004955
wscript.echo "Case 3"
End Select
输出:案例3
答案 0 :(得分:0)
你的意思是在Ruby中,以下工作
case "0049555"
when /0048.*/ then print "case 1"
when /0049.*/ then print "case 2"
end
我担心这对Vbscript不起作用而且我从未见过它在powershell中使用但在那里我无法确定。
你可以用这种方式模拟它..
Function evaluate(pattern, string)
Set re = new RegExp
With re
re.Pattern = pattern
re.Global = true
re.IgnoreCase = true
End With
If re.test(string) Then evaluate = true
End Function
CallID = "0049555"
Select Case true
case evaluate("0048.*", CallID)
wscript.echo "Case 1"
case evaluate("0049.*", CallID)
wscript.echo "Case 2"
case evaluate("0050.*", CallID)
wscript.echo "Case 3"
End Select
给出案例2
答案 1 :(得分:0)
Select Case (InStr(Left(CallID,4), "0049")) OR (InStr(Left(CallID,4), "+49"))
case 1
wscript.echo "Case 1"
case 0
wscript.echo "Case 0"
case else
wscript.echo "Case else"
End Select
我现在解决了这个问题。但非常感谢@peter