The AutoHotkey documentation lists two methods of comparing a variable to items in a list.
if Var in MatchList
if Var contains MatchList
What's the difference between if var in
and if var contains
?
Hopefully some examples will help demonstrate the difference.
Example of if var in MatchList
:
Match:
F3::
example := "pizza" ; Contains a matching string.
if example in This,is,a,tasty,pizza
MsgBox, %example% found in MatchList
Negative match:
F3::
example := "pizz" ; Contains no matching string.
if example not in This,is,a,tasty,pizza
MsgBox, %example% not found in MatchList
Example of if var contains MatchList
:
Match:
F3::
example := "ice" ; Contains a matching "i" substring.
if example contains p,i,z,z,a
MsgBox, %example% contains MatchList item(s)
Negative match:
F3::
example := "doggy" ; Contains no matching substring.
if example not contains p,i,z,z,a
MsgBox, %example% does not contain MatchList item(s)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.