IfInString / IfNotInString

Checks if a variable contains the specified string.

IfInString, var, SearchString
IfNotInString, var, SearchString
Position := InStr(Haystack, Needle [, CaseSensitive?, StartingPos]])



var The name of the variable whose contents will be searched for a match.
SearchString The string to search for.



The built-in variables %A_Space% and %A_Tab% contain a single space and a single tab character, respectively, which might be useful when searching for these characters alone.

Another command can appear on the same line as this one. In other words, both of these are equivalent:

IfInString, MyVar, abc, Gosub, Process1
IfInString, MyVar, abc
	Gosub, Process1



InStr(), StringGetPos, IfEqual, if var in/contains MatchList, if var between, if var is type, Blocks, Else



Haystack = abcdefghijklmnopqrs
Needle = abc
IfInString, Haystack, %Needle%
	MsgBox, The string was found.
	Sleep, 1