str_locate {stringr} | R Documentation |
Locate the position of the first occurence of a pattern in a string.
str_locate(string, pattern)
string |
input character vector |
pattern |
pattern to look for. See regex for
description. |
numeric matrix. First column gives start postion of match, and second column gives end position.
regexpr
which this function wraps
str_extract
for a convenient way of extracting matches
str_locate_all
to locate position of all matches
fruit <- c("apple", "banana", "pear", "pinapple") str_locate(fruit, "a") str_locate(fruit, "e")