spec

Software for Diffraction

2.4.5.2. - String Functions



index(s1, s2)
Returns an integer indicating the position of the first occurrence of string s2 in string s1, counted from 1, or zero if s1 does not contain s2.

split(string, arr)
Splits the string string at space characters and assigns the resulting substrings to successive elements of the associative array arr, starting with element 0. The space characters are eliminated. The functions returns the number of elements assigned.

split(string, arr, delimiter)
As above, but splits the string into elements that are delimited by the string delimiter. The delimiting characters are eliminated.

substr(string, m)
Returns the portion of string string that begins at position m, counted from 1.

substr(string, m, n)
As above, but the returned string is no longer than n.

length(string)
Returns the length of the string string.

sprintf(format [, a, b, ... ])
Returns a string containing the formatted print. See sprintf() in a C-language reference manual.

sscanf(string, format, a [, b, ... ])
Scans the literal string or string variable string for data, where format contains a format specification in the same style as the C language scanf() function. Each subsequent argument is a variable name or array element that will be assigned the values scanned for. The function returns the number of items found in the string.