Detect and return all matching patterns from character vector.

Detect and return first matching pattern from character vector.

chr_extract(x, pat, ignore.case = FALSE, collapse = NULL,
  invert = FALSE, na = TRUE, ...)

chr_extract_first(x, pat, ignore.case = FALSE, invert = FALSE,
  na = TRUE, ...)

chr_extract_links(x, collapse = NULL)

chr_extract_words(x, collapse = NULL)

chr_extract_mentions(x, collapse = NULL)

chr_extract_hashtags(x, collapse = NULL)

chr_extract_phone(x, collapse = NULL)

Arguments

x

Character vector

pat

Pattern (regex) to extract from text.

ignore.case

Logical indicating whether to ignore capitalization. Defaults to false.

collapse

Text inserted between extracted matches. If non-null (the default) a vector of matches is returned for each inputted string.

invert

Logical indicating whether to extract matching portion (default) or, if this value is true, non-matching portions of text.

na

Logical indicating whether to return NA values for input elements without matches. Defaults to true.

...

Other named arguments passed to gregexpr.

Value

Vector of matches extracted from input text.

Character vector of matches extracted from input text.