Page 1 of 1

Filter

Posted: Sat Jun 23, 2012 7:20 am
by Nakia
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?

Re: Filter

Posted: Sat Jun 23, 2012 9:47 am
by Mark
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

Re: Filter

Posted: Sat Jun 23, 2012 12:33 pm
by Nakia
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.