1
2empty_result <- function(text, pattern, perl=TRUE, ...) {
3  match <- regexpr(pattern, text, perl = perl, ...)
4  num_groups <- length(attr(match, "capture.names"))
5  structure(
6    c(
7      replicate(num_groups, list(), simplify = FALSE),
8      list(character()),
9      list(list())
10    ),
11    names = c(attr(match, "capture.names"), ".text", ".match"),
12    row.names = integer(0),
13    class = c("tbl_df", "tbl", "data.frame")
14  )
15}
16