filter

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

filter

J. Landman Gay via use-livecode
Hi all,

I am surely missing something here with filter.

I have a field with some lines like:
...
[500]
text yadda
yadda
[100]
...
And want to filter the field that only the lines with [...] remain in the field.

So I thought
...
filter fld 1 with "[*"
...
would do the job, but that EMPTIES the field!?
Obviously this [ interferes with some REGEX mechanism of filter?
So what should I use now?

Any hints very appreciated!


Best

Klaus
--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
Hi Klaus,
Maybe iterate the lines - untested...

repeat for each line l in fld 1
  if and( offset( “[“, l) > 0 , offset(“]”, l) > 0 ) then put line l of fld 1 into tList
end repeat

put tList

Best,
Keith

> On 19 Nov 2020, at 15:19, Klaus major-k via use-livecode <[hidden email]> wrote:
>
> Hi all,
>
> I am surely missing something here with filter.
>
> I have a field with some lines like:
> ...
> [500]
> text yadda
> yadda
> [100]
> ...
> And want to filter the field that only the lines with [...] remain in the field.
>
> So I thought
> ...
> filter fld 1 with "[*"
> ...
> would do the job, but that EMPTIES the field!?
> Obviously this [ interferes with some REGEX mechanism of filter?
> So what should I use now?
>
> Any hints very appreciated!
>
>
> Best
>
> Klaus
> --
> Klaus Major
> https://www.major-k.de
> [hidden email]
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
> So I thought
> ...
> filter fld 1 with "[*"
> ...
> would do the job, but that EMPTIES the field!?
> Obviously this [ interferes with some REGEX mechanism of filter?
> So what should I use now?

I think:

   filter fld 1 with "[[]*"

Should do the trick...

Basically, you can use '[...]' to 'escape' the operators in the wildcard
pattern (i.e. *, [ and ?).

Hope this helps,

Mark.

P.S. Wildcard patterns are a lot simpler than general regexes, but
'filter' can do both "filter ... with regex pattern ..." interprets the
pattern the same as matchText/replaceText.

--
Mark Waddingham ~ [hidden email] ~ http://www.livecode.com/
LiveCode: Everyone can create apps

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
Hi Mark,

> Am 19.11.2020 um 16:38 schrieb Mark Waddingham via use-livecode <[hidden email]>:
>
>> So I thought
>> ...
>> filter fld 1 with "[*"
>> ...
>> would do the job, but that EMPTIES the field!?
>> Obviously this [ interferes with some REGEX mechanism of filter?
>> So what should I use now?
> I think:
>  filter fld 1 with "[[]*"
> Should do the trick...
> Basically, you can use '[...]' to 'escape' the operators in the wildcard pattern (i.e. *, [ and ?).

ah, get it! So I added this accordingly:
...
filter fld 1 with "[[]*[]]"
...
to be on the safe side and it works like a charme!

> Hope this helps,

Yes, it does, thank you very much!

> Mark.
>
> P.S. Wildcard patterns are a lot simpler than general regexes, but 'filter' can do both "filter ... with regex pattern ..." interprets the pattern the same as matchText/replaceText.
>
> --
> Mark Waddingham ~ [hidden email] ~ http://www.livecode.com/
> LiveCode: Everyone can create apps

Best

Klaus

--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
Hi Keith,

> Am 19.11.2020 um 16:38 schrieb Keith Clarke via use-livecode <[hidden email]>:
>
> Hi Klaus,
> Maybe iterate the lines - untested...
> repeat for each line l in fld 1
>  if and( offset( “[“, l) > 0 , offset(“]”, l) > 0 ) then put line l of fld 1 into tList
> end repeat
> put tList

yes, sure, but "lazy moi" wanted to use FILTER and also understand why my first script did not work. :-)

> Best,
> Keith

Best

Klaus

--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
Ha, yes I understand that desire - and Mark’s one-character escape trick beats my hack to bypass the lair of the regex demon! :D
Best,
Keith

> On 19 Nov 2020, at 15:51, Klaus major-k via use-livecode <[hidden email]> wrote:
>
> Hi Keith,
>
>> Am 19.11.2020 um 16:38 schrieb Keith Clarke via use-livecode <[hidden email]>:
>>
>> Hi Klaus,
>> Maybe iterate the lines - untested...
>> repeat for each line l in fld 1
>> if and( offset( “[“, l) > 0 , offset(“]”, l) > 0 ) then put line l of fld 1 into tList
>> end repeat
>> put tList
>
> yes, sure, but "lazy moi" wanted to use FILTER and also understand why my first script did not work. :-)
>
>> Best,
>> Keith
>
> Best
>
> Klaus
>
> --
> Klaus Major
> https://www.major-k.de
> [hidden email]
>
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
No one escapes the lair of the Regex Demon. Except for maybe Riddick.

Bob S


On Nov 19, 2020, at 8:15 AM, Keith Clarke via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

Ha, yes I understand that desire - and Mark’s one-character escape trick beats my hack to bypass the lair of the regex demon! :D
Best,
Keith

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
On 11/19/20 7:38 AM, Mark Waddingham via use-livecode wrote:

> I think:
>
>    filter fld 1 with "[[]*"
>
> Should do the trick...

As an alternative,

filter fld 1 with regex pattern "^\[+"

also does the trick.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
Hi Mark,

> Am 19.11.2020 um 18:07 schrieb Mark Wieder via use-livecode <[hidden email]>:
> On 11/19/20 7:38 AM, Mark Waddingham via use-livecode wrote:
>> I think:
>>   filter fld 1 with "[[]*"
>> Should do the trick...
> As an alternative,
> filter fld 1 with regex pattern "^\[+"
> also does the trick.

thanks, but REGEX is still a TAD over my head. ;-)

> --
> Mark Wieder
> [hidden email]

Best

Klaus

--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
The chronicles of regex - a potential blockbuster there, Bob! :-)
Best,
Keith

> On 19 Nov 2020, at 16:49, Bob Sneidar via use-livecode <[hidden email]> wrote:
>
> No one escapes the lair of the Regex Demon. Except for maybe Riddick.
>
> Bob S
>
>
> On Nov 19, 2020, at 8:15 AM, Keith Clarke via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:
>
> Ha, yes I understand that desire - and Mark’s one-character escape trick beats my hack to bypass the lair of the regex demon! :D
> Best,
> Keith
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
I don’t think I could watch! Oh the horror!!!!!

Bob S


> On Nov 19, 2020, at 9:17 AM, Keith Clarke via use-livecode <[hidden email]> wrote:
>
> The chronicles of regex - a potential blockbuster there, Bob! :-)
> Best,
> Keith
>
>> On 19 Nov 2020, at 16:49, Bob Sneidar via use-livecode <[hidden email]> wrote:
>>
>> No one escapes the lair of the Regex Demon. Except for maybe Riddick.
>>
>> Bob S
>>
>>
>> On Nov 19, 2020, at 8:15 AM, Keith Clarke via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:
>>
>> Ha, yes I understand that desire - and Mark’s one-character escape trick beats my hack to bypass the lair of the regex demon! :D
>> Best,
>> Keith
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

RE: filter

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
Klaus.

I use "filter" here and there, mostly with regex or wildCards.

But nothing works for me either,:

Filter yourText with "["
Filter yourText where each contains "["

Not sure what is going on. Where is Thieery?

Craig
-----Original Message-----
From: use-livecode [mailto:[hidden email]] On Behalf
Of Klaus major-k via use-livecode
Sent: Thursday, November 19, 2020 10:19 AM
To: How to use LiveCode <[hidden email]>
Cc: Klaus major-k <[hidden email]>
Subject: filter

Hi all,

I am surely missing something here with filter.

I have a field with some lines like:
...
[500]
text yadda
yadda
[100]
...
And want to filter the field that only the lines with [...] remain in the
field.

So I thought
...
filter fld 1 with "[*"
...
would do the job, but that EMPTIES the field!?
Obviously this [ interferes with some REGEX mechanism of filter?
So what should I use now?

Any hints very appreciated!


Best

Klaus
--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
In reply to this post by J. Landman Gay via use-livecode
On 11/19/20 9:09 AM, Klaus major-k via use-livecode wrote:

> Hi Mark,
>
>> Am 19.11.2020 um 18:07 schrieb Mark Wieder via use-livecode <[hidden email]>:
>> On 11/19/20 7:38 AM, Mark Waddingham via use-livecode wrote:
>>> I think:
>>>    filter fld 1 with "[[]*"
>>> Should do the trick...
>> As an alternative,
>> filter fld 1 with regex pattern "^\[+"
>> also does the trick.
>
> thanks, but REGEX is still a TAD over my head. ;-)

Not really... this is at least as simple as what you just coded:

^ = start at beginning of line
\[ = a literal "[" character ("\" escapes whatever comes next)
+ = at least one of those characters

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
Hi Mark,

> Am 20.11.2020 um 00:55 schrieb Mark Wieder via use-livecode <[hidden email]>:
> On 11/19/20 9:09 AM, Klaus major-k via use-livecode wrote:
>> Hi Mark,
>>> Am 19.11.2020 um 18:07 schrieb Mark Wieder via use-livecode <[hidden email]>:
>>> On 11/19/20 7:38 AM, Mark Waddingham via use-livecode wrote:
>>>> I think:
>>>>   filter fld 1 with "[[]*"
>>>> Should do the trick...
>>> As an alternative,
>>> filter fld 1 with regex pattern "^\[+"
>>> also does the trick.
>> thanks, but REGEX is still a TAD over my head. ;-)
> Not really...

how do you know? 8-)

> this is at least as simple as what you just coded:
>
> ^ = start at beginning of line
> \[ = a literal "[" character ("\" escapes whatever comes next)
> + = at least one of those characters

Thank you, now I am ready to challenge Thierry! :-D

> --
> Mark Wieder
> [hidden email]

Best

Klaus

--
Klaus Major
https://www.major-k.de
[hidden email]


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
Apologies for barging in, but I am confused by regex generally and in this specific example by the function of the terminal ‘+’  If you are only finding one character, why do you need to specify 'at least one' of one char?

Cheers

David G

> On 20 Nov 2020, at 8:44 am, Klaus major-k via use-livecode <[hidden email]> wrote:
>
>> ^ = start at beginning of line
>> \[ = a literal "[" character ("\" escapes whatever comes next)
>> + = at least one of those characters

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
On 11/20/20 3:27 AM, David V Glasgow via use-livecode wrote:
> Apologies for barging in, but I am confused by regex generally and in this specific example by the function of the terminal ‘+’  If you are only finding one character, why do you need to specify 'at least one' of one char?

Ha!
Yeah, I actually mistyped that (moi?).

"^\[" is all that's necessary for the filter command.

...but Klaus' form of "[[]*[]]" is actually better if the field has
[500] and then text

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: filter

J. Landman Gay via use-livecode
Yeah, not confusing at all. ;-P

Bob S


On Nov 20, 2020, at 9:55 AM, Mark Wieder via use-livecode <[hidden email]<mailto:[hidden email]>> wrote:

On 11/20/20 3:27 AM, David V Glasgow via use-livecode wrote:
Apologies for barging in, but I am confused by regex generally and in this specific example by the function of the terminal ‘+’  If you are only finding one character, why do you need to specify 'at least one' of one char?

Ha!
Yeah, I actually mistyped that (moi?).

"^\[" is all that's necessary for the filter command.

...but Klaus' form of "[[]*[]]" is actually better if the field has
[500] and then text

--
Mark Wieder
[hidden email]<mailto:[hidden email]>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode