Learn R Programming

icd (version 3.3)

str_pair_match: Match pairs of strings to get named vector

Description

Match a character vector against a regular expression with at least two parenthetic groupings, returning named vector.

Usage

str_pair_match(string, pattern, pos, swap = FALSE, ...)

Arguments

string

vector of strings

pattern

vector of regular expression which should match exactly two strings for each element in stringr. If pos is specified, this rule is relaxed.

pos

optional pair of integers with positions of the first and second desired matches, when multiple matches are made by the regular expression

swap

logical scalar, whether to swap the names and values. Default is not to swap, so the first match becomes the name.