is among the words AND find words
Jim Hurley
jhurley0305 at sbcglobal.net
Thu Dec 22 10:17:53 EST 2011
Dave,
Ah! Those mighty regular expressions. Soooom day I'll have to study up on them.
Yes that works very nicely.
The other method (one that I understand ;) ) now boils down to this:
on mouseUp
put field 1 into tText
put containsWord("time", tText)
end mouseUp
function containsWord tWord, tList
replace quote with "" in tList
replace "." with "" in tList
return tWord is among the tokens of tList
end containsWord
Jim
> Late to the thread.
>
> If the purpose is just to see whether the word exists in a string, would this work (using regular expressions)?
>
> on mouseUp
> put "Some timely text with time, and more." into tString
> put "time" into tTarget
> put containsWord(tTarget, tString)
> end mouseUp
>
> function containsWord tWord, tString
> put "(?i)\b" & tWord & "\b" into tRE
> return matchText(tString, tRE)
> end containsWord
>
> "\b" is the regular expression "word boundary" pattern.
> "(?i)" makes the match case insensitive.
>
> Cheers
> Dave
More information about the use-livecode
mailing list