need help with filter and regex

Mike Bonner bonnmike at gmail.com
Tue Jun 2 11:55:59 EDT 2015


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
>



More information about the use-livecode mailing list