Matchtext to find a series of words

Jim Ault JimAultWins at yahoo.com
Wed Nov 29 20:17:32 EST 2006


On 11/29/06 3:37 PM, "J. Landman Gay" <jacque at hyperactivesw.com> wrote:
> This looks promising, thanks. It looks like there is no single-pass
> method, but since filter is pretty fast it may do okay. I didn't even
> quote your regex explanation, I don't want to touch it. :)

You mention single pass...
Question: Single pass of what?
Single pass of each text block or all text blocks together?

Doing all as one block --------------------
--with tracing to know which are matches

put 0 into cnt
repeat for each line LNN in variableList
   add 1 to cnt
   do "get "&LNN
  replace cr with tab in it
  put cnt & LNN && it & cr after newBlock
end repeat
--now all the blocks are their own line in the aggregate

put allWordsPresent(newBlock, wordList) into residualBlock

if residualBlock is empty then
   put "no matches anywhere"
else
    --word 1 of each line =
   --       (the variable number & variable name)
   --by concatenating it is unlikely they will form a match to one of your
    search words or tokens
end if

-------------------------
>> function allWordsPresent textStr, wordList
>>   replace cr with tab in textStr
>>   set the wholematches to true
>>   repeat for each word WRD in wordList
>>     filter textStr with ("*" & WRD & "*")
>>   end repeat
>>   return not (textStr is empty)
>> end  allWordsPresent


Jim Ault
Las Vegas


> Jim Ault wrote:
> 
>> I would tackle this using the filter command
>> 
>> replace cr with tab in textStr
>> set the wholematches to true
>> filter textStr with "*"& token1&"*"
>> filter textStr with "*"& token2&"*"
>> filter textStr with "*"& token3&"*"
>> if textStr  is empty then return false
>> else return true
>> 
>> A better form would be
>> 
>> function allWordsPresent textStr, wordList
>>   replace cr with tab in textStr
>>   set the wholematches to true
>>   repeat for each word WRD in wordList
>>     filter textStr with ("*" & WRD & "*")
>>   end repeat
>>   return not (textStr is empty)
>> end  allWordsPresent
>





More information about the use-livecode mailing list