StringFunctions

classes
   head           left           right          tail           
   is_name        len            substr         

SYNTAX

obj = new StringFunctions()

DESCRIPTION

The StringFunctions class contains functions which you can apply to a strdef. This class exists purely for the utility of preventing pollution of name space with string operations.

EXAMPLES

objref strobj
strobj = new StringFunctions()


len

StringFunctions

SYNTAX

length = strobj.len(str)

DESCRIPTION

Return the length of a string.


substr

StringFunctions

SYNTAX

index = strobj.substr(s1, s2)

DESCRIPTION

Return the index into s1 of the first occurrence of s2. If s2 isn't a substring then the return value is -1.


head

StringFunctions

SYNTAX

strobj.head(str, "regexp", result)

DESCRIPTION

The result contains the head of the string up to but not including the regexp. returns index of last char.


tail

StringFunctions

SYNTAX

strobj.tail(str, "regexp", result)

DESCRIPTION

The result contains the tail of the string from the char following regexp to the end of the string. return index of first char.

Other functions can be added as needed, eg., index(s1, c1), char(s1, i), etc. without polluting the global name space. In recent versions functions can return strings.


right

StringFunctions

SYNTAX

strobj.right(str, n)

DESCRIPTION

Removes first n characters from str and puts the result in str.


left

StringFunctions

SYNTAX

.left(str, n)

DESCRIPTION

Removes all but first n characters from str and puts the result in str


is_name

StringFunctions

SYNTAX

.is_name(str)

DESCRIPTION

Returns 1 if the str is the name of a symbol, 0 otherwise. This is so useful that the same thing is available with the top level name_declared function.


neuron/general/classes/strfun.hel : 1642 Jul 19