Millisecond Forums

Can you search text in an expression?

https://forums.millisecond.com/Topic16715.aspx

By writekristin - 7/15/2015

I would like to increase a counter value based on whether the stimulus name contains certain letters.  I know I can get the stimulus name using picture.picturename.currentitem, but is there a way to then search whether this name contains a certain letter or phrase?
By Dave - 7/15/2015

Yes, you can use the string functions detailed in the functions reference in the documentation's language reference section.

searchSearches the first string for any occurence of the second string. If the string is found, it returns the zero based index of the first occurence. If the string is not found, it returns -1.search("benjamin", "ben")
search("benjamin", "benji")
search("benjamin", "jamin")
0
-1
3