Re-2: search for regular expression in text and put the results into an array

Jim Ault jimaultwins at yahoo.com
Fri Nov 6 13:43:49 EST 2009


On Nov 5, 2009, at 2:16 PM, runrev260805 at m-r-d.de wrote:

> Hi,
> first thanks to all for the suggestions. As i am unfamiliar with the  
> offset function and i was a little in a hurry i used Jim´s script  
> and extended it to my needs.
> @Jim
> Line 8 of your example should be
> filter xmlBlock without "<statuses type='array'>*"
> shouldn´t it.
Perhaps, since I just typed the script without testing in order to  
give the basic structure I use.
However,
the scheme was to make each line in the xmlBlock start with <statuses  
type='array'> and include only those lines.

"<statuses type='array'><status>blah blah blah<moredata>blah</ 
moredata></status>"
"<statuses type='array'><status>blah blah blah<moredata>blah</ 
moredata></status>"
"<statuses type='array'><status>blah blah blah<moredata>blah</ 
moredata></status>"
"<statuses type='array'><status>blah blah blah<moredata>blah</ 
moredata></status>"

Now the repeat loop will cycle through them and do the parsing.

Glad it helped you move on to the next programming task.

Jim Ault
Las Vegas

> -------- Original Message --------
> Subject: Re: search for regular expression in text and put the  
> results into an array (05-Nov-2009 6:41)
> From:    Jim Ault <jimaultwins at yahoo.com>
> To:      runrev260805 at m-r-d.de
>
>> I don't use the xml library to do the simple tag processing for three
>> types of tags
>> Chunk expressions are so fast that I get better speed and control of
>> the data parsing.
>>
>> ------- Use these steps to get started----
>>
>> on test
>>    replace cr with empty in xmlBlock
>>    replace quote with "'" in xmlBlock  --(apostrophe ' char)
>>    --now you can use quote expressions without worries
>>    --   such as in the next line
>>    replace "<statuses type='array'>" with (cr & "<statuses
>> type='array'>") in xmlBlock
>>    filter xmlBlock with "<statuses type='array'>*"
>>
>>    put 0 into statusCount
>>    repeat for each line statusArrLine in xmlBlock
>>       replace "<status>" with (cr & "<status>") in statusArrLine
>>       replace "</status>" with ("</status>" & cr) in statusArrLine
>>       filter statusArrLine with "<status>*"
>>
>>       repeat for each line statusTag in statusArrLine
>>          replace "<status>" with empty in statusTag
>>          replace "</status>" with empty in statusTag
>>          --now we have the data only, and on a single line
>>          add 1 to statusCount
>>          put statusTag into storArray[statusCount]
>>
>>       end repeat
>>    end repeat
>>
>>    --> statusCount = total
>>    --> storArray[num] = strings storage
>> end test
>>
>> Hope this helps.




More information about the use-livecode mailing list