Skip to content

Commit

Permalink
Remove dependency on stringr (closes #9)
Browse files Browse the repository at this point in the history
  • Loading branch information
EllaKaye committed Jan 2, 2024
1 parent 8a7b27c commit 64c5517
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Imports:
httr,
lubridate,
readr,
rlang,
stringr
rlang
Suggests:
testthat (>= 3.0.0)
Config/testthat/edition: 3
4 changes: 3 additions & 1 deletion R/string-helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
#' @examples extract_numbers("1, -3, 16, -136")
#'
extract_numbers <- function(x) {
stringr::str_extract_all(x, "-?\\d+") |>

matches <- gregexpr(pattern = "-?\\d+", text = x)
regmatches(x, matches) |>
unlist() |>
as.numeric()
}

0 comments on commit 64c5517

Please sign in to comment.