Skip to content

Commit 156312f

Browse files
better regex
1 parent 41563a9 commit 156312f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

R/roxygen-examples-add-remove.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ remove_roxygen_mask <- function(text) {
2929
#' #' @examples c(1, 2)
3030
#' @keywords internal
3131
remove_roxygen_header <- function(text) {
32-
gsub("^\\s*@examples(If)?(\\s|\t)*", "", text, perl = TRUE)
32+
gsub("^[\\s\t]*@examples(If)?(\\s|\t)*", "", text, perl = TRUE)
3333
}
3434

3535
#' Add the roxygen mask to code

R/roxygen-examples-find.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
#' @importFrom rlang seq2
88
#' @keywords internal
99
identify_start_to_stop_of_roxygen_examples_from_text <- function(text) {
10-
starts <- grep("^#'\\s*@examples(If\\s|\\s|\t|$)", text, perl = TRUE)
10+
starts <- grep("^#'(\\s|\t)*@examples(If\\s|\\s|\t|$)", text, perl = TRUE)
1111
if (length(starts) < 1L) {
1212
return(integer())
1313
}
14-
stop_candidates <- grep("^[^#]|^#'\\s*@", text, perl = TRUE)
14+
stop_candidates <- grep("(^[^#]|^#'[\\s\t]*@)", text, perl = TRUE)
1515
stops <- map(starts, match_stop_to_start, stop_candidates) %>%
1616
flatten_int()
1717
if (length(stops) < 1L) {

0 commit comments

Comments
 (0)