R/indexing.R

Defines functions `$.rematch_records` `$.rematch_allrecords`

#' @rdname re_exec
#' @export $.rematch_records
#' @export

`$.rematch_records` <- function(x, name) {
  if (! name %in% c("match", "start", "end")) {
    stop("'$' match selector must refer to 'match', 'start' or 'end'")
  }

  vapply(x, "[[", name, FUN.VALUE = if (name == "match") "" else 1L)
}

#' @rdname re_exec
#' @export $.rematch_allrecords
#' @export

`$.rematch_allrecords` <- function(x, name) {
  if (! name %in% c("match", "start", "end")) {
    stop("'$' match selector must refer to 'match', 'start' or 'end'")
  }

  lapply(x, "[[", name)
}
MangoTheCat/rematch2 documentation built on May 7, 2019, 2:11 p.m.