Navigation

Operators and Keywords

Function List:

C++ API

: substr (s, offset)
: substr (s, offset, len)

Return the substring of s which starts at character number offset and is len characters long.

Position numbering for offsets begins with 1. If offset is negative, extraction starts that far from the end of the string.

If len is omitted, the substring extends to the end of s. A negative value for len extracts to within len characters of the end of the string

Examples:

substr ("This is a test string", 6, 9)
     ⇒ "is a test"
substr ("This is a test string", -11)
     ⇒ "test string"
substr ("This is a test string", -11, -7)
     ⇒ "test"

This function is patterned after the equivalent function in Perl.

Package: octave