Matchtext to find a series of words

Ken Ray kray at sonsothunder.com
Wed Nov 29 17:08:30 EST 2006


On 11/29/06 3:26 PM, "J. Landman Gay" <jacque at hyperactivesw.com> wrote:

> I need a matchtext/regex that will find a series of words in a block of
> text, no matter whether they are together or not, and ignoring carriage
> returns. For example:
> 
> See if all of these words: dog cat dinosaur
> 
> are in this text:
> 
> "The purple dinosaur inadvertently stepped on the cat.<cr>
> The white dog howled."
> 
> Should return true. Is there such a thing?

Well, you can do this, but there may be a more efficient way:

  put (matchText(tText,"(?si)\bdog\b") and \
    matchText(tText,"(?si)\bcat\b") and
    matchText(tText,"(?si)\bdinosaur\b"))

If I keep trying, maybe I can come up with a more efficient one-liner...

Ken Ray
Sons of Thunder Software, Inc.
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com





More information about the use-livecode mailing list