Site Tools


pattern
no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


pattern [2007/05/15 01:28] (current) – created - external edit 127.0.0.1
Line 1: Line 1:
 +# $EPIC: pattern.txt,v 1.3 2007/05/15 01:28:58 jnelson Exp $
 +======Synopsis:======
 +$__pattern__(<pattern> <word list>)
 +
 +======Technical:======
 +   * If the <pattern> argument is omitted the empty string is returned.
 +   * This function returns a space separated word list of all of the words in <word list> that are matched by <pattern>.
 +   * This is the complement to $[[filter]](), and the inverse of $[[rpattern]]().
 +   * Remember that the words in <word list> are [[what is a word|words]], so double quoted words are not honored unless you turn [[xdebug]] dword on.
 +   * The <pattern> is also a [[what is a word|word]], so you should not put double quotes around it unless you have turned [[xdebug]] dword on.  This is an important difference from epic4.
 +   * Double quotes around words are not lost if you have [[xdebug]] dword turned on.  This is an important difference from epic4.
 +   * There is no reasonable way to support matching a <pattern> that has spaces (a dword) against a word list that does not have spaces (a uword list), since by rule a uword can **never** contain a space, so it can't match.  It has to be all one way or the other.
 +
 +======Practical:======
 +This function lets you "filter" <word list> through a pattern, keeping all
 +of the words that match the pattern and discarding all of the words that
 +do not match the pattern.  By appending * to a string and using this
 +function, you can quickly find all words in a word list that start with
 +a particular substring.
 +
 +======Returns:======
 +The list of words from <word list> that are matched by <pattern>.
 +
 +======History:======
 +This function first appeared in "plus-2" (post-ircII, pre-EPIC)
 +
 +======Examples:======
 +<file>
 +$pattern(*oo* foobar blah booya) returns "foobar booya"
 +$pattern(*a* hello there bob)    returns nothing
 +$pattern(irc* $myservers())      returns all servers you are connected to
 +                                 that start with the string "irc".
 +</file>
  
pattern.txt · Last modified: 2007/05/15 01:28 by 127.0.0.1