Filter

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Filter

Post by Nakia » Sat Jun 23, 2012 7:20 am

Hi,

I have a container that I want to filter based upon a Global Variable.

The container has multiple lines of text with each line containing 4 words (TAB Del)
I want to be able to filter the container down to only the lines which match their 4th word to the global variable.

I am currently trying the filter but because the entire line doesn't match the variable it obviously doesn't work.


anyone got some ideas?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Filter

Post by Mark » Sat Jun 23, 2012 9:47 am

Hi Nakia,

Here's a simple example:

Code: Select all

on mouseUp
     put "x" into myVar
     put "a b c x" & cr & "e f g x" & cr & "x i j y" into myList
     put cr after myList
     put replacetext(myList,"[a-z]+[ ][a-z]+[ ][a-z]+[ ]x"&cr,"")
end mouseUp
Maybe you will want to replace the last line with

Code: Select all

 put replacetext(myList,"[a-zA-Z0-9]+[ ][a-zA-Z0-9]+[ ][a-zA-Z0-9]+[ ]x"&cr,"")
and you could also use ASCII values to allow for diacritics:

"[a-zA-Z0-9" & numToChar(142) & "]+[][a-z...." etc

Kind regards,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Filter

Post by Nakia » Sat Jun 23, 2012 12:33 pm

Thanks Mark,

What i ended up doing what using the wild card on the front of the Search Pattern.
This will work for me because the first 3 word of every line wont ever contain the 4th word.

Looking at your solution however yours seems a better way.

Post Reply