Match positions

re_exec and re_exec_all are similar to re_match and re_match_all,
but they also return match positions. These functions return match
records. A match record has three components: match, start, end, and
each component can be a vector. It is similar to a data frame in this
respect.

Unfortunately R does not allow hierarchical data frames (i.e. a column of a
data frame cannot be another data frame), but rematch2 defines some
special classes and an $ operator, to make it easier to extract parts
of re_exec and re_exec_all matches. You simply query the match,
start or end part of a column:

pos$first$match

#> [1] "Ben" "Millard"

pos$first$start

#> [1] 3 2

pos$first$end

#> [1] 5 8

re_exec_all is very similar, but these queries return lists, with
arbitrary number of matches: