Vectorized over str
, [value
], from
and
(to
or length
). to
and length
are mutually exclusive.to
has priority over length
. If from
is a two-column matrix, then the first column is used as
from
and the second one as to
. In such case
arguments to
and length
are ignored.
Of course, the indices are code point-based, and not
byte-based. Note that for some Unicode strings, the
extracted substrings may not be well-formed, especially if
the input is not NFC-normalized, includes byte order marks,
Bidirectional text marks, and so on. Handle with care.
Indices are 1-based, i.e. an index equal to 1 denotes the
first character in a string, which gives a typical Rlook-and-feel. Argument to
defines the last index of
the substring, inclusive.
For negative indices in from
or to
, counting
starts at the end of the string. E.g. index -1 denotes the
last code point in the string. Negative length
means
counting backwards.
In stri_sub
, out-of-bound indices are silently
corrected. If from
> to
, then an empty string
is returned.
In stri_sub<-
, ``strange'' configurations of indices
work as string concatenation at the front, back, or middle.