Next Previous Contents

78. substr

Synopsis

Extract a substring from a string

Usage

String_Type substr (String_Type s, Integer_Type n, Integer_Type len)

Description

The substr function returns a substring with length len of the string s beginning at position n. If len is -1, the entire length of the string s will be used for len. The first character of s is given by n equal to 1.

Example

     substr ("To be or not to be", 7, 5);
returns "or no"
Notes

The expression substr(s, n, 1) is equivalent to the array index expression s[n-1].

See Also

is_substr, strlen


Next Previous Contents