Title
[M5]
substr( ) — Extract substring
Syntax
string matrix substr(string matrix s, real matrix b, real matrix l)
string matrix substr(string matrix s, real matrix b)
Description
substr(s, b, l) returns the substring of s starting at position b and continuing for a length of l,
where
1. b specifies the starting position; the first character of the string is b = 1.
2. b > 0 is interpreted as distance from the start of the string; b = 2 means starting at the
second character.
3. b < 0 is interpreted as distance from the end of string; b = 􀀀1 means starting at the last
character; b = 􀀀2 means starting at the second from the last character.4. l specifies the length; l = 2 means for two characters.
5. l < 0 is treated the same as l = 0: no characters are copied.
6. l . is interpreted to mean to the end of the string.
substr(s, b) is equivalent to substr(s, b, .) for strings that do not contain binary 0. If there
is a binary 0 to the right of b, the substring from b up to but not including the binary 0 is returned.
When arguments are not scalar, substr() returns element-by-element results.
Conformability
substr(s, b, l):
s: r1 c1
b: r2 c2
l: r3 c3; s, b, and l r-conformable
result: max(r1; r2; r3) max(c1; c2; c3)
substr(s, b):
s: r1 c1
b: r2 c2; s and b r-conformable
result: max(r1; r2) max(c1; c2)
Diagnostics