User Tools

Site Tools


before

Overview:

before(count chars text)

Technical:

The before() function returns the part of text before the countth instance of any of the characters in chars.

The chars argument may contain multiple characters. If it contains a space, you should surround it with double quotes (which won't count).

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.

If count is a negative number, the characters are counted from the end of the string.

Defined Behaviors:

Call Return Value Because
before(1 ! hop!user@host) hop
before(1 / /usr/local/bin/epic) the empty string (there is nothing before the first /)
before(-1 / /usr/local/bin/epic) /usr/local/bin
before(-2 / /usr/local/bin/epic) /usr/local
before(5 / /usr/local/bin/epic) the empty string (there are not 5 /'s in the string)
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(1 @ /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 <count> argument first appeared in “+11”

before.txt · Last modified: 2016/08/02 22:12 by sgrubnick