How best to check if string contains any of a list of substrings?
keith.clarke at me.com
Thu Nov 1 05:41:17 EDT 2018
What is the most efficient way to test whether a variable containing a string such as “my test phrase” contains one of several variable substrings, such as “est” OR “phr” OR... ?
So far I’ve tried (without luck) approaches that simplify into...
put “my test phrase” into myTestPhrase
put “*est*” & cr & “*phr*” into tSubstrings
if myTestPhrase is among the lines of tSubstrings then answer “true”
repeat for each line L in tSubstrings
if myTestPhrase contains L then answer “true”
Both seem to be failing - do I have the wrong syntax or approach to the problem?
More information about the Use-livecode