re2r (version 0.2.0)

re2_extract: Extract matching patterns from a string.

Description

Extract matching patterns from a string. Vectorised over string and pattern.

Usage

re2_extract(string, pattern, anchor = UNANCHORED, parallel = FALSE,
  grain_size = 1e+05, ...)

re2_extract_all(string, pattern, anchor = UNANCHORED, parallel = FALSE, grain_size = 1e+05, ...)

Arguments

string

a character vector

pattern

a character vector or pre-compiled regular expressions

anchor
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 for re2_extract, and a list for re2_extract_all.

See Also

re2_match to extract matched groups.

Examples

Run this code
# NOT RUN {
re2_extract("yabba dabba doo", "(.)")
re2_extract_all("yabba dabba doo", "(.)")

str <- c("Aster", "Azalea x2", "Baby's Breath", "Bellflower")
re2_extract(str, "\\d")
re2_extract(str, "[a-z]+")
re2_extract(str, "\\b\\w{1,3}\\b")

# Extract all matches
re2_extract_all(str, "[A-Za-z]+")
re2_extract_all(str, "\\b\\w{1,3}\\b")
re2_extract_all(str, "\\d")

# }

Run the code above in your browser using DataLab