In an .ahk script how can I test if a string contains another string?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From the autohotkey help file:
InStr(Haystack, Needle [, CaseSensitive = false, StartingPos = 1, Occurrence = 1]): Returns the position of an occurrence of the string Needle in the string Haystack. Unlike StringGetPos, position 1 is the first character; this is because 0 is synonymous with “false”, making it an intuitive “not found” indicator. If the parameter CaseSensitive is omitted or false, the search is not case sensitive (the method of insensitivity depends on StringCaseSense); otherwise, the case must match exactly. If StartingPos is omitted, it defaults to 1 (the beginning of Haystack). Otherwise, specify 2 to start at Haystack’s second character, 3 to start at the third, etc. If StartingPos is beyond the length of Haystack, 0 is returned. If StartingPos is 0 or negative, the search is conducted in reverse (right-to-left) beginning at that offset from the end. Regardless of the value of StartingPos, the returned position is always relative to the first character of Haystack. For example, the position of “abc” in “123abc789” is always 4. Specify 2 for Occurrence to return the position of the second match, 3 for the third match, etc. Related items: RegExMatch(), IfInString, and StringGetPos.