Checks if a variable contains the specified string.
| IfInString, var, SearchString IfNotInString, var, SearchString Position := InStr(Haystack, Needle [, CaseSensitive?, StartingPos]]) |
Parameters
| var | The name of the variable whose contents will be searched for a match. |
| SearchString | The string to search for. |
Remarks
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
Related
InStr(), StringGetPos, IfEqual, if var in/contains MatchList, if var between, if var is type, Blocks, Else
Example
Haystack = abcdefghijklmnopqrs
Needle = abc
IfInString, Haystack, %Needle%
{
MsgBox, The string was found.
return
}
else
Sleep, 1