This shows you the differences between two versions of the page.
— |
beforew [2007/03/02 02:32] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | # $EPIC: beforew.txt,v 1.4 2007/03/02 02:32:04 jnelson Exp $ | ||
+ | ======Synopsis:====== | ||
+ | $__beforew__(<word> <pattern list>) | ||
+ | |||
+ | ======Technical:====== | ||
+ | * If the <word> argument is omitted this function returns the empty string. | ||
+ | * The <pattern list> does not actually need to be a list of wildcard patterns. A list of literal words will work just fine. | ||
+ | * If <word> is not matched by any of the words in <pattern list>, this function returns the empty string. | ||
+ | * Otherwise, the function behaves "as if" the following had been performed: <val> = rmatch(<word> <word/pattern list>) <function_return> = leftw(<val> <word/pattern list>) | ||
+ | * Remember that <pattern list> is a list of [[what is a word|words]]. | ||
+ | |||
+ | ======Practical:====== | ||
+ | This function lets you get the part of <pattern list> that occurs BEFORE | ||
+ | the pattern that is the "best match" for <word>. You can of course use | ||
+ | this function with a list of literal words. | ||
+ | |||
+ | ======Returns:====== | ||
+ | The portion of <pattern list> before the pattern that is the "best match" | ||
+ | of <word>. A word is always "best matched" by itself; see the help file | ||
+ | on pattern matching for more detail. | ||
+ | |||
+ | ======Examples:====== | ||
+ | <file> | ||
+ | $beforew(foobar one two foobar my shoe) returns "one two" | ||
+ | $beforew(booya one two foobar my shoe) returns "" (empty string) | ||
+ | $beforew(foobar o* t* f* m* s*) returns "o* t*" | ||
+ | $beforew(booya o* t* f* m* s*) returns "" (empty string) | ||
+ | $beforew(foobar f* fo* foobar foo* foob*) returns "f* fo*" | ||
+ | </file> | ||
+ | |||
+ | ======History:====== | ||
+ | This function first appeared in "plus 2" (post-ircII, pre-EPIC) | ||