stringr (version 0.3)

str_detect: Detect the presence or absence of a pattern in a string.

Description

Detect the presence or absence of a pattern in a string.

Usage

str_detect(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

  • boolean vector

Details

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

See Also

grepl which this function wraps

Examples

Run this code
fruit <- c("apple", "banana", "pear", "pinapple")
str_detect(fruit, "a")
str_detect(fruit, "^a")
str_detect(fruit, "a$")
str_detect(fruit, "b")
str_detect(fruit, "[aeiou]")

Run the code above in your browser using DataCamp Workspace