str_locate {stringr}R Documentation

Locate the position of the first occurence of a pattern in a string.

Description

Locate the position of the first occurence of a pattern in a string.

Usage

str_locate(string, pattern)

Arguments

string input character vector
pattern pattern to look for. See regex for description.

Value

numeric matrix. First column gives start postion of match, and second column gives end position.

See Also

regexpr which this function wraps

str_extract for a convenient way of extracting matches str_locate_all to locate position of all matches

Examples

fruit <- c("apple", "banana", "pear", "pinapple")
str_locate(fruit, "a")
str_locate(fruit, "e")

[Package stringr version 0.2 Index]