help need to "read from file until xxxx OR yyyy OR zzzz"

Alex Tweedly alex at tweedly.net
Sun Dec 12 18:19:43 EST 2004


At 15:26 12/12/2004 -0700, Dar Scott wrote:


>On Dec 12, 2004, at 3:09 PM, Randy Padawer wrote:
>
>>Let's say a text file occasionally includes the words dogs, cats, and 
>>fleas. I need to "read until" any of these words without skipping any.
>
>Unless the file is huge, read it in in one piece with the URL method.
>
>Then repeatedly parse it with matchText or matchChunk.  Match with a 
>pattern includes what you want and also allows you to obtain the rest of 
>the data for processing more.  I'm guessing that the pattern you want 
>includes the front of the string, a bunch of characters, and then either 
>one of the words.  The rest is everything after that.  If you need help 
>with the regex pattern, just ask.
>
>It would be nice to give a char # offset to matchText or matchChunk, but I 
>don't know how.

Can't you just do
  matchText(char currOffset to -1 of theString, tRegEx, tVars)

Or, if that won't work,
   put "." & currOffset & tRegEx into tempRegEx
   matchText(theString, tempRegEx, tVars)
(so the first match is the .N where N is the offset ) ?
(Ugly, but I've seen something like this used before in Perl, where 
ugliness seemed natural :-)

-- Alex.


More information about the use-livecode mailing list