str_detect2: Improved str_detect

View source: R/strings.R

str_detect2R Documentation

Improved str_detect

Description

A wrapper for stringr's str_detect so that one can get the matches values, not just logical values. This restores the functionality of base-r's equivalent function, gsub.

Usage

str_detect2(string, pattern, value = F)

Arguments

string

(character vector) A character vector.

pattern

(character vector) Pattern to look for (REGEX).

value

(log scalar) Whether to return the matched values instead of logical values. Default = F.

Value

A character vector. Note that it will have a length longer than one if one of the inputs has that.

Examples

str_detect2(letters[1:10], pattern = "[acbde]")
str_detect2(letters[1:10], pattern = "[acbde]", value = T)

Deleetdk/kirkegaard documentation built on May 2, 2024, 7:12 p.m.