Details

If pattern is empty, then the result is NA
and a warning is generated.

Argument start controls the start position in str
where there is a match to a pattern.
to gives the end position.

Indexes given by from or to are of course 1-based,
i.e., an index 1 denotes the first character
in a string. This gives a typical R look-and-feel.

For negative indexes in from or to, counting starts
at the end of the string. For instance, index -1 denotes the last code point
in the string.

If you wish to test for a pattern match at an arbitrary
position in str, use stri_detect.

stri_startswith and stri_endswith are convenience functions.
They call either stri_*_fixed, stri_*_coll,
or stri_*_charclass, depending on the argument used.
Relying on these underlying functions directly will make your code run
slightly faster.

Note that testing for a pattern match at the start or end of a string
has not been implemented separately for regex patterns.
For that you may use the "^" and "$" meta-characters,
see stringi-search-regex.