Helper function for globbing character vectors
Arguments
- x
A vector of characters
- pattern
Wildcard globbing pattern
- value, ...
Additional parameters passed to
grep
. Note:value
is by defaultTRUE
; whenNA
,...
is passed togrepl
.
Examples
x <- c("apple", "banana", "peach", "pear", "orange")
glob(x, "*e")
#> [1] "apple" "orange"
glob(x, "pea*", value = FALSE)
#> [1] 3 4
glob(x, "*an*", value = NA)
#> [1] FALSE TRUE FALSE FALSE TRUE
path <- system.file("R", package = "mark")
glob(list.files(path), "r*")
#> character(0)