AutoHotkey documentation列出了两种将变量与列表中的项进行比较的方法。
如果 MatchList 中的 Var 如果 Var 包含 MatchList
if var in
和if var contains
之间的区别是什么?
答案 0 :(得分:4)
希望一些例子可以帮助证明这种差异。
if var in MatchList
的示例:
<强>匹配强>
F3::
example := "pizza" ; Contains a matching string.
if example in This,is,a,tasty,pizza
MsgBox, %example% found in MatchList
否定匹配:
F3::
example := "pizz" ; Contains no matching string.
if example not in This,is,a,tasty,pizza
MsgBox, %example% not found in MatchList
if var contains MatchList
的示例:
<强>匹配强>
F3::
example := "ice" ; Contains a matching "i" substring.
if example contains p,i,z,z,a
MsgBox, %example% contains MatchList item(s)
否定匹配:
F3::
example := "doggy" ; Contains no matching substring.
if example not contains p,i,z,z,a
MsgBox, %example% does not contain MatchList item(s)