str_match_each: str match each

Description Usage Arguments Value Author(s) Examples

Description

Run each regex on each string.

Usage

1
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

1
2
3
4
5
6
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 May 31, 2019, 7:38 a.m.