R/mparse.R

Defines functions mparse

mparse <-
        function(x,
                 pattern =  "\\[(.*)\\] (.*?): (.*$)",
                 names   = c("commit",
                             "commit_date",
                             "commit_description")) {

                output <- list()

                for (i in seq_along(names)) {

                        new_col_contents <-
                                stringr::str_replace_all(
                                        string = x,
                                        pattern = pattern,
                                        replacement = as.character(glue::glue("\\{i}"))
                                )

                        output[[i]] <- new_col_contents
                        names(output)[i] <- names[i]

                }

                output %>%
                        tibble::as_tibble()

        }
meerapatelmd/glitter documentation built on Sept. 9, 2021, 6:21 p.m.