Searching for a word when it's more than one word
Stephen MacLean
smaclean at madmansoft.com
Sat Sep 1 00:48:44 EDT 2018
Hi All,
First, followed Keith Clarke’s thread and got a lot out of it, thank you all. That’s gone into my code snippets!
Now I know, the title is not technically true, if it’s 2 words, they are distinct and different. Maybe it’s because I’ve been banging my head against this and some other things too long and need to step back, but I’m having issues getting this all to work reliably.
I’m searching for town names in various text from a list of towns . Most names are one word, easy to find and count. Some names are 2 or 3 words, like East Hartford or West Palm Beach. Those go against distinct towns like Hartford and Palm Beach. Others have their names inside of other town names like Colchester and Chester.
"is among the words of” or "is among the trueWords of” works great to find single words, but only works on single words and doesn’t consider “Chester’s” to be ”Chester”, it isn't.
“is in” works great for finding multiple words like “East Hartford” and "West Palm Beach", finds “Chester” in “Chester’s” but also finds “chester” in “Colchester”.
At this point, I’ve been using different methods for single word towns vs multi-word towns and while generally effective, trying to accommodate for these and other oddities has made it a complete mess of code.
If someone has done something similar, or can point me in the right direction, it would be greatly appreciated.
TIA,
Steve MacLean
More information about the use-livecode
mailing list