re2_extract: Extract matching patterns from a string.

Description Usage Arguments Value See Also Examples

Description

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

Usage

1
2
3
4
5
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

see UNANCHORED

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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")

re2r documentation built on May 2, 2019, 12:35 p.m.