strExtractAll: Extract all pattern occurances

View source: R/strExtractAll.R

strExtractAllR Documentation

Extract all pattern occurances

Description

Uses gregexpr() and regmatches() internally.

Usage

strExtractAll(x, pattern, fixed = FALSE)

Arguments

x

character. Character vector. NA values are allowed.

pattern

character(1). Regular expression pattern. Evalutes with gregexpr() internally.

fixed

logical(1). If TRUE, pattern is a string to be matched as is. Otherwise, will match by regular expression.

Value

list. List of character vector extractions. Returns character(0L) for match failure, NA_character_ for NA.

Note

Updated 2023-09-25.

See Also

  • gregexpr() , regmatches().

  • stringi::stri_extract_all().

  • stringr::str_extract_all().

  • https://stringr.tidyverse.org/articles/from-base.html

Examples

object <- strExtractAll(
    x = c("apples x4", "bag of flour", "bag of sugar", "milk x2", NA),
    pattern = "[a-z]+"
)
print(object)

acidgenomics/acidbase documentation built on Jan. 26, 2024, 4:26 p.m.