stringr (version 0.3)

str_locate_all: Locate the position of all occurences of a pattern in a string.

Description

Locate the position of all occurences of a pattern in a string.

Usage

str_locate_all(string, pattern)

Arguments

string
input character vector
pattern
pattern to look for, as defined by a POSIX regular expression. See the ``Extended Regular Expressions'' section of regex for details.

Value

  • list of numeric matrices. First column gives start postion of match, and second column gives end position.

Details

Vectorised over string. pattern should be a single pattern, i.e. a character vector of length one.

See Also

regexpr which this function wraps

str_extract for a convenient way of extracting matches

str_locate to locate position of first match

Examples

Run this code
fruit <- c("apple", "banana", "pear", "pineapple")
str_locate_all(fruit, "a")
str_locate_all(fruit, "e")

Run the code above in your browser using DataLab