How best to check if string contains any of a list of substrings?

Keith Clarke keith.clarke at me.com
Thu Nov 1 05:41:17 EDT 2018


Folks,
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”
end repeat 

Both seem to be failing - do I have the wrong syntax or approach to the problem?

TIA
Keith 



More information about the use-livecode mailing list