re_match_all: Extract all matches of a regular expression

View source: R/package.R

re_match_allR Documentation

Extract all matches of a regular expression

Description

This function is a thin wrapper on the gregexpr base R function, to provide an API that is easier to use. It is similar to re_match, but extracts all matches, including potentially named capture groups.

Usage

re_match_all(pattern, text, ...)

Arguments

pattern

Regular expression, defaults to be a PCRE expression. See regex for more about regular expressions.

text

Character vector.

...

Additional arguments to pass to regexpr.

Value

A list of character matrices. Each list element contains the matches of one string in the input character vector. Each matrix has a .match column that contains the matching part of the string. Additional columns are added for capture groups. For named capture groups, the columns are named.


rematch documentation built on Aug. 30, 2023, 5:08 p.m.