Description Usage Arguments Value Examples
Vectorized over string
; compares each element of string
to every element of patterns
.
Expects that only one of the patterns provided will match the input string,
and returns the position of said match. If the match is of length 0,
(e.g. from a special match like $) end will be one character less than start.
If more than one of patterns provided match input string, returns position of first
matching element from patterns provided. Wraps str_locate
with map
.
1 | str_locate_whichever(string, patterns)
|
string |
Input vector. Either a character vector, or something coercible to one. |
patterns |
Patterns to look for, as a character vector. Each string in
the vector may be used as |
An integer matrix. First column gives start position of whichever pattern matched, and second column gives end position.
1 2 | fruit <- c("apple", "banana", "pear", "pineapple")
str_locate_whichever(fruit, c("ap", "ba", "pe"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.