Skip to content

Commit

Permalink
try readr for checbox_choices()
Browse files Browse the repository at this point in the history
ref #500
  • Loading branch information
wibeasley committed Jul 14, 2023
1 parent 1bdde82 commit 5f89356
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions R/metadata-utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ regex_named_captures <- function(pattern, text, perl = TRUE) {
checkbox_choices <- function(select_choices) {
checkmate::assert_character(select_choices, any.missing=FALSE, len=1, min.chars=1)

pattern_checkboxes <- "(?<=\\A| \\| |\\| )(?<id>\\d{1,}), (?<label>[^|]{1,}?)(?= \\| |\\| |\\Z)"

regex_named_captures(pattern = pattern_checkboxes, text = select_choices)
strsplit(select_choices, split = "|", fixed = TRUE)[[1]] |>
I() |>
readr::read_csv(
col_names = c("id", "label"),
col_types = "cc"
)
# pattern_checkboxes <- "(?<=\\A| \\| |\\| )(?<id>\\d{1,}), (?<label>[^|]{1,}?)(?= \\| |\\| |\\Z)"
# regex_named_captures(pattern = pattern_checkboxes, text = select_choices)
}

0 comments on commit 5f89356

Please sign in to comment.