User Tools

Site Tools


before

Differences

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

Link to this comparison view

before [2007/03/02 02:32]
127.0.0.1 external edit
before [2016/08/02 22:12] (current)
sgrubnick
Line 1: Line 1:
-# $EPIC: before.txt,​v 1.3 2007/03/02 02:32:04 jnelson Exp $ +======Overview:====== 
-======Synopsis:====== +before(//count// //chars// //text//)
-$__before__([<count>] <​char>​ <text>)+
  
 ======Technical:​====== ======Technical:​======
-   ​* ​The <​count>​ and <​char>​ arguments are [[what is a word|dwords]]. ​ This is different from most functions. +The before() function ​returns ​the part of //text// before the //count//th instance ​of any of the characters in //chars//.
-   * The <​count>​ argument is optional, the default value is 1.  <​count>​ must be some non-zero number to be recognized as a count. ​ If <​count>​ is 0, it will be taken as the <​char>​ argument, and <​count>​ will default to 1! +
-   * If <​count>​ is positive, then the return value of this function is the initial portion of <​text>​ that is before ​the <​count>​th occurrence of any of the characters in <​char>​. +
-   * If <​count>​ is negative, then the return value of this function ​is the initial port of <text> that is before the <count>th-to-last occurrence ​of any of the characters in <​char>​(eg. counting backwards from the end)+
  
-======Practical:​====== +The //chars// argument may contain ​multiple ​characters.  ​If it contains ​space, ​you should surround ​it with double quotes ​(which won't count).
-There are many cases where you need to break apart strings that contain +
-certain ​characters ​as delimiters.  ​The $[[userhost function|userhost]]() +
-function returns ​"​user@host"​ and if you want the username, then +
-$before(@ $[[userhost function|userhost]]()) will give it to you.  If +
-you want the hostname, check out $[[after]]().+
  
-======Returns:​====== +If //text// does not contain //count// instances ​of any of the characters ​in //chars//, or if //count// is 0, then it returns ​the empty string.
-The input string <text> before the <count>th occurrence ​of any character +
-in <​char>​. ​ The default value for <countis 1.  Negative <​count>​s count +
-going backwards from the end.+
  
-======History:​====== +If //count// is a negative number, the characters are counted from the end of the string.
-This function first appeared in "​+10"​ (post ircIIpre-EPIC) Support for +
-the <​count>​ argument first appeared in "​+11"​+
  
-======Examples:====== +======Defined Behaviors:====== 
-<​file>​ +^ Call ^ Return Value ^ Because ^ 
-$before(hop!jnelson@wicked.neato.org    returns "hop!jnelson"​ +before(1 ! hop!user@host        | hop | | 
-$before(-1 ​! hop!jnelson@wicked.neato.org)  ​returns "​hop"​ +| before(1 / /​usr/​local/​bin/​epic) ​  | the empty string | (there is nothing before the first /)| 
-$before(-2 ​. hop!jnelson@wicked.neato.org)  ​returns "​hop!jnelson@wicked"​ +before(-1 ​/ /​usr/​local/​bin/​epic)  ​| /​usr/​local/​bin | | 
-$before(2 . hop!jnelson@wicked.neato.org)   returns "hop!jnelson@wicked.neato"​ +before(-2 ​/ /​usr/​local/​bin/​epic)  ​| /usr/local | 
-$before(3 !@. hop!jnelson@wicked.neato.orgreturns ​"hop!jnelson@wicked+before(5 / /​usr/​local/​bin/​epic)   | the empty string | (there are not 5 /'s in the string)| 
-</file>+| before(/ /​usr/​local/​bin/​epic) ​    | the empty string | (//count// defaults to 1) | 
 +| before(0 ! hop!user@host)         | the empty string | (the //count// argument is 0)| 
 +before(/​usr/​local/​bin/​epic) ​  | the empty string | (there is not 1 @'s in the string)
 +| before(/​usr/​local/​bin/​epic) ​      | the empty string | (argument error -- there are not enough words)| 
 +| before() ​                         | the empty string | (no params) | 
 + 
 +======History:​====== 
 +This function first appeared in "+10" ​(post ircII, pre-EPIC). 
 +Support for the <countargument first appeared in "​+11"​
  
before.txt · Last modified: 2016/08/02 22:12 by sgrubnick