re2r (version 0.2.0)

re2_subset: Keep strings matching a pattern.

Description

This is a convenient wrapper around x[re2_detect(x, pattern)]. Vectorised over strings and patterns.

Usage

re2_subset(string, pattern, anchor = 0, omit_na = TRUE, parallel = FALSE,
  grain_size = 1e+05, ...)

Arguments

string

a character vector

pattern

a character vector or pre-compiled regular expressions

anchor
omit_na

omit na result

parallel

use multithread

grain_size

a minimum chunk size for tuning the behavior of parallel algorithms

...

further arguments passed to re2

Value

A character vector.

Examples

Run this code
# NOT RUN {
fruit <- c("apple", "banana", "pear", "pinapple")
re2_subset(fruit, "a")
re2_subset(fruit, "^a")
re2_subset(fruit, "a$")
re2_subset(fruit, "b")
re2_subset(fruit, "[aeiou]")

re2_subset(c("a", NA, "b"), ".")
# }

Run the code above in your browser using DataCamp Workspace