AW: need help with filter and regex

Tiemo Hollmann TB toolbook at kestner.de
Wed Jun 3 02:22:32 EDT 2015


Hi Mike,
thanks for this solution, i didn't thought it would be that easy.
You are right, that it would be a typical db task and actually I was using
valentina for this (could also be done with sqlite).

I was just looking to reduce components of my program installation and with
it potential issues at customer installations, so I tested keeping all data
in properties/arrays and making the selection with a plain repeat loop and
that worked fine and almost with the same performance as a db sql.
Additionally I had to sort the selection coming out of the array selection,
which also worked fine up to LC 6. The issue came with testing LC7, where
sort international has such a massive performance problem, that I now was
looking for alternatives, which was preparing different sorted lists only
once at preopenstack and just filtering these lists. But meanwhile I am
coming to multiple issues, where I am creating lists randomly of unsorted
lines, which have to be sorted international afterwords. And here LC 7
"stops working" and is unusable for a German customer.

Thanks
Tiemo


-----Ursprüngliche Nachricht-----
Von: use-livecode [mailto:use-livecode-bounces at lists.runrev.com] Im Auftrag
von Mike Bonner
Gesendet: Dienstag, 2. Juni 2015 17:56
An: How to use LiveCode
Betreff: Re: need help with filter and regex

You can do interesting things with just filter..

For example, to end up with items that contain a string in string one, and
number 2 IS a specific number you could do something like this

filter tMyVar with "*;*stringtofind*;*;*;345;*"
This will match any value of key and any value for string 1 that has the
string to find in it, any value for string 2, any value for number 1, and
345 for number 2, then match the remainder of the string.
For begins with, it would be ;stringtofind*;  for an exact match it would be
;stringtofind;

Having said all that, it seems that a repeat for each loop would work very
well, and should be pretty fast even with 7.

set the itemdelimiter to ";"
repeat for each line tLine in tMyVar
 if item 2 of tLine contains stringtofind and item item 5 of tLine is 345
then put tLine & cr after tNewData end repeat delete the last char of
tNewData -- tNewdata now contains what you're looking for.

In fact, it shouldn't be too awful difficult to build a generic function
that you could pass arguments to detailing what items to check for what
values in what way.

I love the way Andres dblib builds its queries up, if you get a chance I'd
call it recommended reading.

Finally, while I love arrays, i'm wondering if there is a reason you aren't
using sqlite for this?  It seems like it would be so much easier to have
sqlite hand you what you're looking for.

On Tue, Jun 2, 2015 at 9:19 AM, Tiemo Hollmann TB <toolbook at kestner.de>
wrote:

> Hello,
>
>
>
> in the course of the massiv LC 7 problem with sort international 
> (which is approved by Runrev) I am looking for a workaround for my 
> repeat selection and sorting with filter, as Richard H. advised.
>
>
>
> I don't have much experience with filter, beside of some easy filters 
> nor regex. Today I am selecting records from an array with multiple 
> selections in a repeat loop. If a combine this array to do a filter on 
> it, it looks like this:
>
> Key;string1;string2;number1;number2;string3; etc.
>
> Today I am selecting like: if string1 contains/begins with searchitem 
> and
> number2 is/is not x then
>
> 1.       I don't understand whats the difference between filter with /
> filter matching
>
> 2.       As far as I see, I don't get here far with a standard filter and
> probably would need a regex to specify in which item of my line I want 
> to do the selection. Perhaps with the number of semicolons?
>
> Any initial help with a regex filter on this issue is appreciated.
>
> Tiemo
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
use-livecode at lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list