Site Tools


# $EPIC: copattern.txt,v 1.4 2007/03/02 02:32:04 jnelson Exp $


$copattern(<pattern> <var1> <var2>)


The <pattern> argument is a dword, which is different than most functions.

This function is the complementary operation of cofilter

This function is closely related to pattern, which returns all of the words in a word list that do not match a wildcard pattern.

All of the co* functions take a wildcard pattern, and two variable names. The variables should contain word lists and each variable should have the same number of words. Each of the words in the first list are matched against the wildcard pattern, and depending on result, the corresponding word in the second list is included or excluded in the return value.

The copattern function returns all those words in $<var2> that correspond in position to those words in $<var1> that match the <pattern>.

Parsing ends whenever the shorter of the two word lists runs out of words. Therefore, the two word lists should have the same number of words.

The wildcard <pattern> may be optionally surrounded by double quotes, if the pattern contains spaces. The double quotes are not considered part of the wildcard pattern.


When you have two variables, one that contains a list of control data, and another that contains a list of secondary data, and you wish to retrieve the secondary data, but you need to do it based on a query of the control data, you might use this function. One possible use might be if one variable held your friends list, and another held their access levels.


The words from $<var2> that correspond to all of the words in $<var1> that are not matched by <pattern>.


@ friends = []
@ levels  = [20 10]
$copattern(* friends levels)       returns "20"
$copattern(* friends levels)       returns "10"
$copattern(*@*.com friends levels)         returns "10 20"
$copattern(*@*.net friends levels)         returns ""      (empty string)
copattern.txt · Last modified: 2007/03/02 02:32 by