Переглянути джерело

detect empty match

pull/27/head
Garrick Aden-Buie 6 роки тому
джерело
коміт
2d1a45cccb
1 змінених файлів з 1 додано та 0 видалено
  1. +1
    -0
      R/regex.R

+ 1
- 0
R/regex.R Переглянути файл

expand_matches <- function(m) { expand_matches <- function(m) {
if (m[1] == -1) return(NULL) if (m[1] == -1) return(NULL)
m_length <- attr(m, "match.length") m_length <- attr(m, "match.length")
if (identical(as.vector(m[[1]]), 1L) && m_length == 0) return(NULL)
x <- purrr::map2(m, m_length, ~ c(.x, .x + .y)) x <- purrr::map2(m, m_length, ~ c(.x, .x + .y))
x <- as.data.frame(do.call(rbind, x)) x <- as.data.frame(do.call(rbind, x))
names(x) <- c("start", "end") names(x) <- c("start", "end")

Завантаження…
Відмінити
Зберегти