我在 vbscript 中有下面的模式来打开/关闭我的灯。它捕获案例"turn on the third bedroom light."
但是,是否有一种优雅的方式也可以"turn on the light in the third bedroom"
使用一体式模式捕获案例?
我知道我可以(light|lite)
以单独的模式分离案例并使用条件逻辑,但我一直在寻找一种优雅的模式,因为我仍在学习正则表达式。
请记住,任何模式都必须排除这种情况"third bedroom closet"
,如下面的模式所示。另请注意,vbscript 不支持负面看法(我认为)。
oRegExp.Pattern = "(third).(bedroom (?!closet)).*(light|lite)"
if oRegExp.Test(sVoice) then gProcessLight home.ThirdBedroom.Light,vPropValue