Created
January 12, 2025 22:13
-
-
Save francisbarton/30ae5dbe75cd6d8db71ad4c3919bb11e to your computer and use it in GitHub Desktop.
gregg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #' Conveniently wrap a regular expr in glue::glue_data() and pass to `grepl()` | |
| #' | |
| #' Use {glue} expressions in grepl (and put the arguments the right way round) | |
| #' https://glue.tidyverse.org/articles/wrappers.html | |
| #' | |
| #' @param x A character vector to check | |
| #' @param rx A string that after processing by glue_data() will be used as a | |
| #' regex pattern in `grepl()` | |
| #' @param ... Arguments passed onto `grepl()` | |
| #' @param g The parent frame of gregg, which must be passed through to `glue()` | |
| #' @keywords internal | |
| # old_gregg <- \(x, rx, ...) grepl(glue(rx), x, ...) | |
| # gregg <- \(x, rx, ..., e = parent.frame()) grepl(glue(rx, .envir = e), x, ...) | |
| gregg <- \(x, rx, ..., g = parent.frame()) grepl(glue_data(g, rx), x, ...) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment