Problem with IF statement

I have the variable “path” that is equal to “/JGM001:2365ceb030728cxx/Settings/Input1/AI1_name”

and then I’d like to check if path contain “AI1_name”

so i do :
if ("AI1_name" in path)

but really, it does not work, and I need to be able to

Try string.find:

if (path.find("AI1_name"))

The ‘in’ keyword is used to find elements in arrays and tables, but not strings.

if ("AI1_name" == split(path,"/").pop())
If it appears at the end of the path

or, it could be any part of the path…
if ( split(path,"/").find("AI1_name")!=null)

or, as a substring…
if (path.find("AI1_name")!=null)

@philmy 's suggestion works most of the time, but don’t forget that array.find() returns 0 if the substring is at the beginning of the string, and both 0 and null are treated as false in squirrel.