User Tools

Site Tools


corpattern

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

Synopsis:

$corpattern(<string> <var1> <var2>)

Description:

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

This function is the reverse operation of copattern, and the complementary operation of corfilter.

This function is closely related to rpattern, which returns all of the wildcard patterns in a word list that match a literal string.

All of the cor* functions take a literal string, and two variable names. The first variable should contain a word list of wildcard patterns, and the second variable should contain a word list. The string is matched against each of the patterns in the first list, and depending on the result, the corresponding word in the second list is included or excluded in the resturn value.

The corpattern function returns all those words in $<var2> that correspond in position to those patterns in $<var1> that match the <string>.

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 literal <string> may be optionally surrounded by double quotes, if the word contains spaces. The double quotes are not considered part of the string for the purposes of matching.

Returns:

The words from $<var2> that correspond to all of the patterns in $<var1> that match the <string>.

Examples:

@ friends = [ooga!bob@*.foo.com *!tom@*.com]
@ levels  = [20 10]
$corpattern(ooga!bob@lace.foo.com friends levels)       returns "20"
$corpattern(hype!tom@bar.com friends levels)            returns "10"
corpattern.txt · Last modified: 2007/03/02 02:32 (external edit)