str_match_each: str match each

str_match_eachR Documentation

str match each

Description

Run each regex on each string.

Usage

str_match_each(string, pattern)

Arguments

string

Character vector to parse.

pattern

Character vector of the same length with regular expressions. Also each regular expression should have the same number of capture groups/parentheses.

Value

A character matrix with the matched groups.

Author(s)

Toby Dylan Hocking

Examples

genotype <- c("AA", "TT", "GA", "TAATAAA", "TAAATAA")
two <- function(x)sprintf("^(?<A>%s)(?<B>%s)$", x, x)
snp <- two("[ATCG]")
taa <- two("TAA|TAAA")
pat <- c(snp, snp, snp, taa, taa)
str_match_each(genotype, pat)

tdhock/revector documentation built on June 14, 2022, 12:22 a.m.