str_nth_instance_indices: Get the indices of the \(n\)th instance of a pattern.
Description
The \(n\)th instance of an pattern will cover a series of character
indices. These functions tell you which indices those are.
Usage
str_nth_instance_indices(string, pattern, n)
str_first_instance_indices(string, pattern)
str_last_instance_indices(string, pattern)
Arguments
string
A character vector. These functions are vectorized over this
argument.
pattern
A character vector. Pattern(s) specified like the pattern(s)
in the stringr`` package (e.g. look at [stringr::str_locate()]). If this has length >1 its length must be the same as that ofstring`.
n
Then \(n\) for the \(n\)th instance of the pattern.
Value
A two-column matrix. The \(i\)th row of this matrix gives the start
and end indices of the \(n\)th instance of pattern in the \(i\)th
element of string.
Details
str_first_instance_indices(...) is just
str_nth_instance_indices(..., n = 1).
str_last_instance_indices(...) is just str_nth_instance_indices(..., n = -1).