matchtext question using regex

ron rbarber at yhb.att.ne.jp
Fri May 4 13:41:49 EDT 2007


Regex question for use in matchtext

I want to find word A followed by word B.  (quickly)
So:
put "this is my big dog called cat." into thetext
put "my.{0,5}dog" into reg

And
put matchtext(thetext,reg)
returns true because I use a period so it is counting characters but I 
need it to count words. I have tried various combinations of \b and \w 
to no avail.

Something like :
put "my([^ ]* ){0,5}dog" into reg
works but only for words followed by spaces, not punctuation for 
example. These could be included but surely there is a more elegant and 
faster way?

Can someone help me out with this?


BTW, is it true that setting the wholematches to true and using 
wordoffset only returns 'words' that are followed by a space? So that 
in the example sentence above, 'cat' is not found because it is 
followed by a period? Is this correct?


Thanks
Ron




More information about the use-livecode mailing list