How to make if (expression) with repeated part concise Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
donsonmd
Posts: 55
Joined: 19 Feb 2017, 05:57

How to make if (expression) with repeated part concise

Post by donsonmd » 29 Nov 2021, 07:08

Hello,

I have a script with an if (expression), which has a repeated part, str3 !=.


If (str3 != "Jan") && (str3 != "Feb") && (str3 != "Mar") && (str3 != "Apr") && (str3 != "May") && (str3 != "Jun") && (str3 != "Jul") && (str3 != "Aug") && (str3 != "Sep") && (str3 != "Oct") && (str3 != "Nov") && (str3 != "Dec")


I know that the following is NOT working. Is there any way to simplify it?


If (str3 != ("Jan" && "Feb" && "Mar" && "Apr" && "May" && "Jun" && "Jul" && "Aug" && "Sep" && "Oct" && "Nov" && "Dec"))


Thank you.

User avatar
thqby
Posts: 403
Joined: 16 Apr 2021, 11:18
Contact:

Re: How to make if (expression) with repeated part concise  Topic is solved

Post by thqby » 29 Nov 2021, 07:48

regular expression.
if !(str ~= "^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)$")

donsonmd
Posts: 55
Joined: 19 Feb 2017, 05:57

Re: How to make if (expression) with repeated part concise

Post by donsonmd » 29 Nov 2021, 16:42

Wow, awesome! Thank you @thqby

Post Reply

Return to “Ask for Help (v1)”